NSInternalInconsistencyException以相机模式呈现UIImagePickerController但在照片库模式下正常工作

时间:2014-07-21 15:09:18

标签: ios camera uiimagepickercontroller uiactionsheet

我试图在运行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;

有人能发现我在这里做错了吗?

0 个答案:

没有答案