UIImagePickerController,Check camera
ios, iphone, uiimagepickercontroller, xcode
Solution
use this code and add `UIImagePickerControllerDelegate` delegate in `.h` file
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.delegate = self;
picker.wantsFullScreenLayout = YES;
[self presentModalViewController:picker animated:YES];
}
else
{
UIAlertView *altnot=[[UIAlertView alloc]initWithTitle:@"Camera Not Available" message:@"Camera Not Available" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
altnot.tag=103;
[altnot show];
[altnot release];
}
Problem
``` -(void)viewDidLoad { if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { imagePicker = [[UIImagePickerController alloc] init]; imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; imagePicker.showsCameraControls = NO; [self.view addSubview:imagePicker.view]; } else { // UIAlertView… } } -(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; imagePicker.delegate = self; [self presentViewController:imagePicker animated:NO completion:NO]; } ``` I want to put out an alert when you do not have a camera. IPhone app launch and move in this code. But, Crash (This Error > `return UIApplicationMain(argc, argv, nil, NSStringFromClass([CameraAppDelegate class])); > Thread 1: signal SIGABRT)` when run in a simulator. Why is this?