如何解决此问题。
我已将UIView放在UIViewController中。然后在UIView里面放置15个UImageView并为每个UIImageView提供1到15的标记。
我使用的代码为:
images=[[NSMutableArray alloc]initWithObjects:[UIImage imageNamed:@"Navarre-Family-Eye-Care-Navarre-Florida-Optometrist-Santa-Christmas-Toy-Safety.jpg"],[UIImage imageNamed:@"Christmas-Wallpapers-HD-Picture.jpg"],[UIImage imageNamed:@"Christmas-Wallpaper-jesus-9413550-1024-768.jpg"],[UIImage imageNamed:@"tree.jpg"],[UIImage imageNamed:@"luxury-christmas-napkins-father-christmas-1635-p.jpg"],[UIImage imageNamed:@"Navarre-Family-Eye-Care-Navarre-Florida-Optometrist-Santa-Christmas-Toy-Safety.jpg"],[UIImage imageNamed:@"Christmas-Wallpapers-HD-Picture.jpg"],[UIImage imageNamed:@"Christmas-Wallpaper-jesus-9413550-1024-768.jpg"],[UIImage imageNamed:@"tree.jpg"],[UIImage imageNamed:@"luxury-christmas-napkins-father-christmas-1635-p.jpg"], nil];
NSString *dd=[NSString stringWithFormat:@"%@", images];
NSLog(@"%@",dd);
randomIndex1=arc4random() % images.count;
selectedImage = [images objectAtIndex:randomIndex1]; //random selected image
NSLog(@"%@",selectedImage);
number = [[NSMutableArray alloc]initWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10", nil];
randomNumber = arc4random() % number.count; //random selected number
NSLog(@"%d",randomNumber);
for (int i = 0; i <randomNumber; i++)
{
NSLog(@"%@", selectedImage);
// _img.image = selectedImage;
//cell.img.image=selectedImage;
}
classname.h文件
@property(weak,nonatomic)IBOutlet UIView *v1;
@property(weak,nonatomic)IBOutlet UIImageView *b1;
@property(weak,nonatomic)IBOutlet UIImageView *b2;
@property(weak,nonatomic)IBOutlet UIImageView *b3;
@property(weak,nonatomic)IBOutlet UIImageView *b4;
@property(weak,nonatomic)IBOutlet UIImageView *b5;
@property(weak,nonatomic)IBOutlet UIImageView *b6;
@property(weak,nonatomic)IBOutlet UIImageView *b7;
@property(weak,nonatomic)IBOutlet UIImageView *b8;
@property(weak,nonatomic)IBOutlet UIImageView *b9;
@property(weak,nonatomic)IBOutlet UIImageView *b10;
@property(weak,nonatomic)IBOutlet UIImageView *b11;
@property(weak,nonatomic)IBOutlet UIImageView *b12;
@property(weak,nonatomic)IBOutlet UIImageView *b13;
@property(weak,nonatomic)IBOutlet UIImageView *b14;
@property(weak,nonatomic)IBOutlet UIImageView *b15;
我在NSLog中获得了一个图像(@&#34;%@&#34;,selectedImage);还有NSLog(@&#34;%d&#34;,randomNumber);例如:Image-SelectedImage,然后是5-randomNumber 将显示5倍的图像。 我的问题是,如何以不同的标签显示图像
表示:我已经在UIView中给出了15个UIImageView
img1-tag as 1
img2-tag as 2
....
img15 -tag as 15
所以我需要在imageview的不同标签上显示图像