2013-12-20 98 views
0

我有2個故事板iPhone和iPad。 從UITableviewcontroller上的按鈕我想用UIImagepicker選擇一個圖像。UIImagepicker立即消失iPhone上顯示

在iPad上,這個工作正常,在iPhone上,UIImagepicker顯示的時間很短,然後他消失了。

調用代碼與iPhone上的iPad相同,因爲我可以看到故事板是idenitical。我在尋找幾個小時,並且看不清爲什麼Imagepicker在iPhone和iPad上消失。 有沒有人有這種行爲的想法? UIImagePicker沒有做任何事情就會消失的原因是什麼?


- (void) go { 
    UIImagePickerController *ipc = [[UIImagePickerController alloc]init]; 
    [ipc setSourceType:UIImagePickerControllerSourceTypeSavedPhotosAlbum]; 
    ipc.delegate=self; 
    [self presentViewController:ipc animated:YES completion:^{}]; 
    } 
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{ 
    NSLog(@"imagePickerControllerDidCancel"); 
    [self dismissViewControllerAnimated:YES completion:^{}]; 
    } 

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { 
    [self.navigationController dismissViewControllerAnimated:NO completion:^{}]; 
    [self dismissViewControllerAnimated:NO completion:^{}]; 
     NSLog(@"didFinishPickingMediaWithInfo"); 
    } 

在iPhone上,日誌「imagePickerControllerDidCancel」從不顯示!

+0

顯示一些代碼!你是否已經加入了調試器,並且/或者取出了其他代碼,以查看是否可以最小化問題? –

+0

聲明這個'UIImagePickerController * ipc'屬性,而不是局部變量 –

回答

0

店揀貨機在強大的類屬性,而不是一個局部變量,就像這樣:

@property(nonatomic, strong) UIImagePickerController *imagePickerController

...

- (void) go { 
    self.imagePickercontroller = [[UIImagePickerController alloc]init]; 
    self.imagePickercontroller.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; 
    self.imagePickercontroller.delegate=self; 
    [self presentViewController:ipc animated:YES completion:nil]; 
} 
+0

不,結果相同。我認爲這與故事板有關,因爲在iPad上代碼rus完美,在iPhone上不是...... tx – Oblomow