0

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.

mrEmpty
  • 841
  • 4
  • 19
  • 36
  • why do you set the camera's picker delegate to the camera view ? does it work for you ? delegate must conform to protocols UINavigationControllerDelegate and UIImagePickerControllerDelegate – giorashc May 03 '12 at 08:24
  • Was simply trying out random stuff in a crazed effort to get it working. – mrEmpty May 03 '12 at 10:13

1 Answers1

0

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.

unexpectedvalue
  • 6,079
  • 3
  • 38
  • 62
  • Hello. Thanks for the hint, researching this led me to the AVFoundation framework, I now have it working. – mrEmpty May 03 '12 at 10:14