私は から を表示しUIImagePicker
ています。UIViewController
私UIViewController
には がいくつかありUITextField
ます。
ユーザーがこれにいくつかの値を入力しUITextField
、 から画像を選択するとUIImagePicker
、メモリ警告が表示され、viewDidLoad が再度呼び出されますが、ユーザーが に入力したすべてのデータUITextField
が欠落しています。どうすればこれに対処できますか?
コード:
- (void) showImageSelector: (UITapGestureRecognizer *) tapGestureRecognizer
{
UIActionSheet *actionSheet;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
actionSheet = [[UIActionSheet alloc] initWithTitle:[PNRConstants kChoosePhoto] delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:[PNRConstants kPhotoLibrary], [PNRConstants kTakeAPicture], nil];
}
else{
actionSheet = [[UIActionSheet alloc] initWithTitle:[PNRConstants kChoosePhoto] delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:[PNRConstants kPhotoLibrary], nil];
}
[actionSheet showInView:self.view.window];
}
#pragma -
#pragma UIActionSheetDelegate
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex != actionSheet.cancelButtonIndex) {
UIImagePickerController *controller = [[UIImagePickerController alloc] init];
controller.delegate = self;
controller.allowsEditing = YES;
if (buttonIndex == 0) {
// Photo Library
controller.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
else {
// Camera
controller.sourceType = UIImagePickerControllerSourceTypeCamera;
}
[self presentViewController:controller animated:YES completion:nil];
}
}