如何在 xcode,iphone 中将字符串值添加到 UIImage 中。显示的代码表示要插入数组中的图像
如何将字符串值添加到 xcode、iphone 中的 UIImage 中。显示的代码表示要插入到数组中的图像。如果我运行此代码,则图像列表将显示在屏幕上,如果我点击任何一张图像图像列表中必须全屏显示。我是 iPhone 新手,我希望有人能帮我解决这个问题。将第二个图像附加到块时,检索空值
NSMutableArray *images = [[NSMutableArray alloc] init];
[images addObject:@"item1.jpg"];
[images addObject:@"item2.jpg"];
[images addObject:@"item3.jpg"];
[images addObject:@"item4.jpg"];
[images addObject:@"item5.jpg"];
[images addObject:@"item6.jpg"];
[images addObject:@"item7.jpg"];
[images addObject:@"item8.jpg"];
[images addObject:@"item9.jpg"];
for (int y = 0; y < rows; y++) {
for (int x = 0; x < columns; x++) {
CGPoint blockOrigin = CGPointMake(x * blockSize.width, y * blockSize.height);
CGRect blockFrame;
blockFrame.size = blockSize;
blockFrame.origin = blockOrigin;
NSString *imagename=[[NSString alloc]init];
imagename=[images objectAtIndex:k];
NSLog(@"image is :::%@",imagename);
// UIImage *blockimg=[[UIImage alloc]init ];
UIImage * blockImage = [UIImage imageNamed:[images objectAtIndex:k]];
NSLog(@"block image is %@",blockimg);
TouchImageView * tiv = [[TouchImageView alloc] initWithFrame:blockFrame];
[[tiv internal] setImage:blockimg];
[self.view addSubview:[tiv autorelease]];
k=k+1;
}
}
此处图像未添加到块图像中。请给我解决方案。
How to add the String value to the UIImage in xcode,iphone .The code shown represents the images to be inserted in an array.If i run this code,the list of images to be displayed on the screen and if i tap any one image among the list of images must shown to a full screen.Am new to iphone ,I hope some one help me out with this problem .when appending the second image to the block,retrieving null value
NSMutableArray *images = [[NSMutableArray alloc] init];
[images addObject:@"item1.jpg"];
[images addObject:@"item2.jpg"];
[images addObject:@"item3.jpg"];
[images addObject:@"item4.jpg"];
[images addObject:@"item5.jpg"];
[images addObject:@"item6.jpg"];
[images addObject:@"item7.jpg"];
[images addObject:@"item8.jpg"];
[images addObject:@"item9.jpg"];
for (int y = 0; y < rows; y++) {
for (int x = 0; x < columns; x++) {
CGPoint blockOrigin = CGPointMake(x * blockSize.width, y * blockSize.height);
CGRect blockFrame;
blockFrame.size = blockSize;
blockFrame.origin = blockOrigin;
NSString *imagename=[[NSString alloc]init];
imagename=[images objectAtIndex:k];
NSLog(@"image is :::%@",imagename);
// UIImage *blockimg=[[UIImage alloc]init ];
UIImage * blockImage = [UIImage imageNamed:[images objectAtIndex:k]];
NSLog(@"block image is %@",blockimg);
TouchImageView * tiv = [[TouchImageView alloc] initWithFrame:blockFrame];
[[tiv internal] setImage:blockimg];
[self.view addSubview:[tiv autorelease]];
k=k+1;
}
}
Here image is not added to the blockImage.Please give me solution for this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用这个,请使用 NSArray
并删除此代码
,然后再次检查断点
use this , please use NSArray
and remove this code
and again check with breakpoint