1
後,我有這樣的代碼來拍照在我的iPhone應用程序:iPhone拍照導致白屏拍照
-(IBAction) getPhoto:(id) sender {
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
else{
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
[self presentModalViewController:picker animated:YES];
}
然後,我有這個其他控制器來管理拍攝的照片:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
[picker.parentViewController dismissModalViewControllerAnimated:YES];
imageTaken.image = image;
NSLog(@"saved!");
}
我試圖在我的iPhone 4(iOS 4.something)上啓動應用程序,在拍攝照片並點擊「使用」後,我得到一個白色屏幕。當直接在XCode(這次是iOS 5)啓動的另一部手機上直接測試應用程序以檢查日誌時,我點擊「使用」,但沒有任何反應,並且日誌被正確打印。
你知道發生了什麼事嗎?我認爲,圖片的屏幕並沒有關閉,但我打電話dismissModalViewController ....
感謝,
Masiar
「[self dismissModalViewControllerAnimated:YES]''是如何工作的?我的應用程序有點雜亂,我的主視圖中有這樣的代碼,即使這樣也刪除了圖片的視圖並讓我繼續使用我的應用程序? – Masiar 2011-06-16 13:13:00
它完全按照['here']提到的方式工作(http://developer.apple.com/library/ios/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006926- CH3-SW30)。它將關閉'self'提供的模式視圖控制器。如果在模式視圖控制器中調用,則消息被傳回給呈現它的視圖控制器。 – 2011-06-16 13:18:57
我偶爾也會看到一個白色的屏幕,但我正在使用最新的函數來處理ImagePicker。我懷疑他在這裏做的任何事情都是原因。 – Oscar 2012-02-07 23:28:15