Saturday, 7 September 2013

UIImagePickerController Showing Black Preview Screen

UIImagePickerController Showing Black Preview Screen

I am having a problem when calling the UIImagePickerController to use the
camera. Sometimes, but more often than none, the preview screen shows to
be black (as the camera itself is covered). After doing some research, it
seems that people where not delegating it correctly..however, I believe my
set up is correct. A restart of the app is what fixes it.
In my .h file I have included UIImagePickerControllerDelegate and
UINavigationControllerDelegate.
Here is the code for the .m file
- (IBAction)camera:(id)sender {
UIImagePickerController *imagePickerController =
[[UIImagePickerController alloc] init];
#if TARGET_IPHONE_SIMULATOR
imagePickerController.sourceType =
UIImagePickerControllerSourceTypePhotoLibrary;
#else
imagePickerController.sourceType =
UIImagePickerControllerSourceTypeCamera;

No comments:

Post a Comment