我试图在运行iOS 7的iPhone 4上展示UIImagePickerController
sourceType UIImagePickerControllerSourceTypeCamera
。它可以使用默认的sourceType
(照片库)显示,没有问题,但是当我尝试以相机模式呈现它时,它会以NSInternalInconsistencyException:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "vXZ-lx-hvc-view-kh9-bI-dsS" nib but didn't get a UITableView.'
我在提出UITableView
的{{1}}内使用UIViewController
,但我不清楚为什么UIImagePickerController
会出现在UITableViewController
中错误。我已将所需的代理人分配到UIViewController
(UIImagePickerControllerDelegate, UIActionSheetDelegate, UINavigationControllerDelegate)
。
以下是我在UIImagePickerController
UIActionSheet
的代码
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 0)
{
//[self.tableView resignFirstResponder];
_myPicker = [[UIImagePickerController alloc] init];
/*
[_myPicker setSourceType:UIImagePickerControllerSourceTypeCamera];
[_myPicker setShowsCameraControls:YES];
[_myPicker setEditing:YES];
[_myPicker setNavigationBarHidden:YES];
[_myPicker setDelegate:self];
*/
_myPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
_myPicker.showsCameraControls = YES;
_myPicker.editing = YES;
_myPicker.navigationBarHidden = YES;
_myPicker.delegate = self;
//self.myPicker = _myPicker;
[self presentViewController:_myPicker animated:YES completion:nil];
}
else if(buttonIndex == 1)
{
_myPicker = [[UIImagePickerController alloc] init];
[self presentViewController:_myPicker animated:YES completion:nil];
}
}
_myPicker
在接口中声明为:
@property(nonatomic)UIImagePickerController *myPicker;
并在实施中合成:
@synthesize myPicker = _myPicker;
有人能发现我在这里做错了吗?