CosmicRabbitMediaInc
CosmicRabbitMediaInc

Reputation: 1175

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.

Upvotes: 0

Views: 616

Answers (1)

Dileep Reghu
Dileep Reghu

Reputation: 879

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
{
//.....
}

Upvotes: 1

Related Questions