我有一个创建 UIImageView 并允许用户从库中选择图像的按钮。
它还以 var 的形式递增,称为“数量”
如果他再次按下按钮,它会做同样的事情。他按了多少次。
-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImageView *subView;
CGRect frame = CGRectMake(60, 100, 200, 200);
subView = [[UIImageView alloc] initWithFrame:frame];
NSString *mediaType = [info
objectForKey:UIImagePickerControllerMediaType];
[self dismissModalViewControllerAnimated:YES];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
UIImage *image = [info
objectForKey:UIImagePickerControllerOriginalImage];
subView.image = image;
if (newMedia)
UIImageWriteToSavedPhotosAlbum(image,
self,
@selector(image:finishedSavingWithError:contextInfo:),
nil);
}
else if ([mediaType isEqualToString:(NSString *)kUTTypeMovie])
{
// Code here to support video if enabled
}
[self.view addSubview:subView];
amount += 1;
NSLog(@"%d", amount);
}
我需要给每个子视图一个唯一的名称,例如 subView1,subView2,subView3....... 以便我以后可以引用它们。
我怎样才能唯一地识别它们?