Tôi đã tạo một ứng dụng để chụp ảnh từ máy ảnh. Đây là mã của tôiNgoại lệ trong iPad, UIImagePickerController phải được trình bày qua UIPopoverController
-(IBAction) showCameraUI {
BOOL hasCamera = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = hasCamera ? UIImagePickerControllerSourceTypeCamera : UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
}
Và thực hiện phương pháp đại biểu này cho được hình ảnh chụp
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[picker dismissModalViewControllerAnimated:YES];
UIImage* image = [info objectForKey:UIImagePickerControllerOriginalImage];
UIImage *yourImageView = image;
}
thực hiện phương pháp này nếu người dùng hủy bỏ bộ điều khiển
- (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker
{
[picker dismissModalViewControllerAnimated:YES];
}
Nhưng nó cho thấy ngoại lệ này. Có ai có bất kỳ ý tưởng tại sao nó được hiển thị ngoại lệ như vậy sau khi thực hiện dòng cuối cùng của hàm showCameraUI.
UIStatusBarStyleBlackTranslucent is not available on this device. 2013-02-07
10:06:06.976 CaptureImage[460:c07] *** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: 'On iPad, UIImagePickerController must be
presented via UIPopoverController'
Something điều này là sai, bởi vì tôi thấy tiêu đề câu hỏi như _ “UIStatusBarStyleBlackTranslucent là không có sẵn trên thiết bị này cho iPad ”_ – Tricertops