Good morning.
I'm having trouble with a UIImagePickerController not showing anything other than white. I have a 320x320 UIImageView, in my main header file:
IBOutlet UIImageView *_cameraView;
Along with:
@property (nonatomic, retain) UIImagePickerController *_cameraPicker;
@property (nonatomic, retain) UIImage *_noCam;
_noCam is an image which is placed in the view if the user has no camera. That works fine.
I'm trying to show (without the standard camera GUI, but that can wait for now) the camera on top of this square view. In my main class I have:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
NSLog(@"viewDidAppear did appear too");
//camera view etc
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
//code here to not allow picture taking, probably put up something saying you don'thave a camera on your device
NSLog(@"no cam available");
_noCam = [UIImage imageNamed:@"noCam.png"];
[_cameraView setImage:_noCam];
} else {
//take the shot
_cameraPicker = [[UIImagePickerController alloc] init];
_cameraPicker.delegate = _cameraView;
_cameraPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
NSLog(@"cam is available");
}
}
I'm guessing I have a problem with setting the delegate. _self gives me an error of type:
'from incompatible type 'ViewController *const _strong'
I'm using NSLogs to check the methods are working, it tells me the viewDidLoad and viewDidAppear method were called and that a camera was detected But then I just get the white view.
Any help would be hugely appreciated.
Thanks.
You need to display the picker somehow, you can either use the default GUI:
[self presentModalViewController:_cameraPicker animated:YES];
Or check out the cameraOverlayView
of UIImagePickerController.