我有一个 UITextView
,图像选择器并在 View 中提交 UIButton
。我想将数据保存在一起,但由于 imagePickerController
使用委托(delegate)方法,因此无论何时在 TextView 中输入数据,它都会被调用。
我是否应该暂时保存来自 didFinishPickingMediaWithInfo
方法的图像,然后在单击提交按钮时检索它?
如果是这样,我该怎么做?
如果没有,如何同时保存textview和image数据?
最佳答案
Should I temporarily save the image from the didFinishPickingMediaWithInfo method and then retrieve it when the submit button is clicked?
是的。
If so, how do I do this?
@property (nonatomic) UIImage *lastSelectedImage;
- (void)imagePickerController:(UIImagePickerController *)thePicker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
self.lastSelectedImage = image;
[thePicker dismissViewControllerAnimated:YES completion:nil]
}
- (void) buttonPressed:(id)sender {
// do something with self.myTextView.text and self.lastSelectedImage
}
关于ios - 如何在 iOS 中保存带有 TextView 数据的图像选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20831091/