我有一个表格 View ,我的表格 View 所有单元格都有按钮。在我的场景中,用户首先点击单元格,该操作转到照片库并从一些图像中选择,最后图像进入单元格。 这部分我已经完成了。
我的问题是图像只来自一个单元格。但我想显示用户选择的单元格的图像。
UIImage * image = info[UIImagePickerControllerOriginalImage];
self.imageView.image = image;
//[self saveImage];
if (_newMedia) {
UIImageWriteToSavedPhotosAlbum(image,
self,
@selector(image:finishedSavingWithError:contextInfo:),
nil);
}
索引方法行的单元格:
BizDetails *bizdetails = [self.bizDetailsArray objectAtIndex:[indexPath row]];
contactNo.text=bizdetails.contactGlobal;
customerId.text=[NSString stringWithFormat:@"%d", bizdetails.bizcustomerId];
businessType.text=bizdetails.contactTypename;
firstName.text=bizdetails.userName;
option1.text=bizdetails.globalOption1;
option2.text=bizdetails.globalOption2;
NSLog(@"getting array %@",option1.text);
NSLog(@"getting array %@",option2.text);
[button addTarget:self action:@selector(useCameraRoll:) forControlEvents:UIControlEventTouchUpInside];
self.imageView.image = [UIImage imageNamed:@"CamIcon.png"];
如果我在 didselectrow 方法中做了什么?
最佳答案
这段代码:
self.imageView.image = [UIImage imageNamed:@"CamIcon.png"];
在应用程序包中找到一个图像并将其加载到某个东西上。不知道是不是牢房,但呆在这里毫无意义。部分原因是它是显式引用而不是单元格引用,部分原因是它引用了捆绑图像。
在选择特定图像之前,它可能被用作默认图像,但它仍然应该是一个单元格引用。
这适用于您使用 bizdetails
的内容设置的所有其他文本。您应该有一个自定义单元格子类,使这些 socket 可用。从代码中不清楚您添加的内容到底是什么,但它看起来不正确。
使用 UIImageWriteToSavedPhotosAlbum
将照片保存到相册。这可能对您没有多大用处,因为您将来无法取回图像。您确实需要一种方法来使用图像(将其保存到磁盘)或图像 URL(使用 writeImageDataToSavedPhotosAlbum:metadata:completionBlock:
将其保存到照片库)来更新您的数据模型。
因此,您需要更改填充单元格的方式以及保存图像的方式,以便在每个单元格上获取特定图像。
关于ios - 从所选单元格的照片库中获取图像问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21625070/