ios - 如何在 iOS 中保存带有 TextView 数据的图像选择器

标签 ios cocoa-touch uiimagepickercontroller

我有一个 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/

相关文章:

ios - 模型 NSArray 是可变的还是不可变的?

objective-c - UIScrollView 无限滚动 setContentOffset

iphone - 通过 SDK 覆盖 iPhone 快门声音

iphone - UIImagepickercontrollerreferenceurl 返回 nil

ios - Swift: UIImagePicker 可以自动打开上次拍摄的照片吗?

ios - NSFetchRequest 与 NSAsynchronousFetchRequest 性能

ios - 当多行标签的字体调整以适应可用宽度时,如何使多行标签的高度正确?

ios - 如何测试 NSMutableArray 中是否有 _NSCFConstantString?

iphone - 自定义 UITableViewCell subview 布局

iphone - Apple 的 iPhone SDK 3.0 CoreDataBooks 示例是否已损坏?