NSInternalInconsistencyException,如何解决此异常?

时间:2011-07-08 11:06:05

标签: iphone objective-c

UIImagePickerController *controller=[[UIImagePickerController alloc] init];
[controller setSourceType:UIImagePickerControllerSourceTypeCamera];
[controller setEditing:YES];
[controller setDelegate:self];    

[self presentModalViewController:controller animated:YES];
[controller release];

嗨,我是iPhone技术的新手,我使用此代码从相机中捕获图像,但是当我点击使用按钮时,我得到了sigmabt错误。

我也使用这个委托mathod来获取图像:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    imagePhoto.image=[info objectForKey:UIImagePickerControllerOriginalImage];
    [picker dismissModalViewControllerAnimated:YES];    
}

我做错了什么?

2 个答案:

答案 0 :(得分:0)

    UIImagePickerController *controller=[[UIImagePickerController alloc] init];

    controller.sourceType=UIImagePickerControllerSourceTypeCamera;

    controller.editing=YES;

    controller.delegate=self;


    [self presentModalViewController:controller animated:YES];

    [controller release];

尝试使用点语法UIImagePickerController已经合成了所有属性。

答案 1 :(得分:0)

我无法告诉任何事情,但你应该放置一个断点,看看哪一行代码导致了崩溃。如果我猜,我认为它与init或发布有关。 (正如我所说,只是一个疯狂的猜测)

正如@madhu所说,请确保您没有尝试在模拟器上访问相机胶卷。使用其他目录或确保您在设备上进行测试。