我顯示UIImagePicker
從我的UIViewController
,在我的UIViewController
我有幾個UITextField
。UIImagePicker收到內存警告稱爲viewDidLoad並清除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];
}
}
分享您的代碼:) – 2012-10-05 05:38:27
不知道該代碼將如何幫助.. – adit
我們的代碼是不是wrong..but產品UR ActionSheet ..我知道這並不重要,但很多時候它造成問題:)謝謝 – 2012-10-05 05:49:10