简体   繁体   中英

getting SIGABRT for UIImagePickerControllerSourceTypeCamera

I'm trying to make a very simple iphone app that displays the real-time camera view of the device, and have added following codes that I found thru researching.

    -(void)viewDidLoad{
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];

imagePicker.delegate = self;

imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;

imagePicker.allowsEditing = YES;

[self presentModalViewController:imagePicker animated:YES];

[imagePicker release];

}

This only causes SIGABRT error, which I have no clue as to what to do with.

Since the above codes seem like a must to implement camera view, are there additional things that I have missed? Didn't think simply loading camera view would stress me... Please help me out.

ps.I'm using xcode 4 btw.

check this before adding

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];

imagePicker.delegate = self;

imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;

imagePicker.allowsEditing = YES;

[self presentModalViewController:imagePicker animated:YES];

[imagePicker release];

}

else
{
//.....
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM