iOS 7 - Black preview screen in UIImagePickerController - ios7

Using the below code to launch the image picker to capture the image. Can any one help out to close this issue...
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
if (self.camera)
{
self.camera = nil;
}
self.camera = [[UIImagePickerController alloc] init];
self.camera.sourceType = UIImagePickerControllerSourceTypeCamera;
self.camera.allowsEditing = NO;
self.camera.delegate = self;
[self presentViewController:self.camera animated:YES completion:NULL];
}

Before launching the UIImagePickerController if you have any GCD in background might be a reason for this issue. In my code have GCD before launching the UIImagePickerController, now removed the GCD it's working fine.

Related

How can I add custom button in UIImagePickerController popover

How can I add custom button in UIImagePickerController popover when I am selecting image from gallery?
Got it. These are by default buttons provided by Apple for UIImagePickerViewController. So there is one property you have to use and property is allowsEditing. You have to set it as YES
So that after selecting photo from gallery or camera, those 2 buttons will be shown.
Code should be like:
-(void)openGallery {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:NULL];
}
-(void)openCamera {
BOOL isCameraPresent = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
if(isCameraPresent) {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
// Add overlay view with custom button on it. Set frames to button as per your choice.
UIView *viewOverlay = [[UIView alloc]initWithFrame:self.view.bounds];
Create and initialise your `UIButton` here
[viewOverlay addSubview:YOUR_BUTTON_OBJECT];
picker.cameraOverlayView = viewOverlay;
[self presentViewController:picker animated:YES completion:NULL];
}
else {
NSLog(#"Camera not present");
}
}
YOU CAN ADD OVERLAY ONLY IF sourceType is UIImagePickerControllerSourceTypeCamera
Make sure that you have confirmed UIImagePickerControllerDelegate protocol in your view controller.
Call those actions on tap of button or action sheet actions as per your choice.
NOTE: UI of popover of UIImagePickerController is dependent on iOS version of device.

When rotate phone to landscape, the UIImagePickerControllerSourceTypePhotoLibrary is turn to camera on sideway

I am new to xcode . In my view controller have images gallery option . User can tab the image to view and add the images. When the user click the add new image option , its show popup there two option like image and camera.
user can add the images from gallery as well as capture the new images from camera. In the case , my camera view working fine. Then i click the gallery view the gallery photos are shown perfectly. But when i rotate the gallery photos view to the landscape ,its automatically goes to the camera in sideway. This is my problem.. I want to when phone rotate the photos gallery in landscape its not going to camera view sideway. Please any one help me.
my code is below
- (void)viewWillAppear:(BOOL)animated {//
[super viewWillAppear:animated];
if (!self.disableGalleryUpdate) {
//This will replace share button in FSImageViewController share button in navigation bar
HPLBarButton *barButton = [HPLBarButton barButtonWithImage:AddNewContractor forTarget:self withSelector:#selector(addObject:)];
self.navigationItem.leftBarButtonItem = barButton;
} else {
self.navigationItem.leftBarButtonItem = nil;
}
APP_DELEGATE.screenHasMultipleOrientation = YES;
[self.navigationController setNavigationBarHidden:NO];
}
- (void)addImageClicked:(id)sender {
[[HPLImageSourceSelectionDeviceManager device] showImageSourceSelectionInView:self.view
withGalleryButtonAction:^{[self camera];}
cameraButtonActionBlock:^{[self gallery];}
];}
-(void)camera
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:picker animated:YES completion:nil];
}
-(void)gallery
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:nil];
}
When i choose image gallery view in potrait
and landscpe
e

ABPeoplePickerNavigationController auto dismiss without showing addressbook book

I am using ABPeoplePickerNavigationController for selection of address book contact by user. With this code behind action of a button:
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
picker.view.frame=self.view.frame;
[self presentModalViewController:picker animated:YES];
[picker release];
When this code runs it rotates the Landscape UI to Portrait and eventually dismisses the controller that presents this ABPeoplePickerNavigationController.
I am getting this problem only in iOS 5, iPad 2. It's working fine with iOS 6.
I don't believe in 5.x that landscape is supported for this picker. However, try doing it via a different PresentationStyle. I believe it should then work in landscape, i.e:
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
picker.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:picker animated:YES];

UIImagepickerController is not showing camera in full view for iPhone 4.2

When I invoke camera using the UIimagepicker controller it does not show in full screen mode on iPhone with iOS version 4.2, but it does work in iOS 5.
Can anyone tell me the code that needs to be changed and what is the problem with existing code?
I am using the following code:
- (IBAction)takePicture:(id)sender
{
UIImagePickerController* imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.showsCameraControls = YES;
imagePicker.allowsEditing = NO;
imagePicker.toolbarHidden = YES;
imagePicker.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
imagePicker.wantsFullScreenLayout = YES;
if ([UIImagePickerController respondsToSelector:#selector(isCameraDeviceAvailable:)])
{
if ([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront])
{
[imagePicker setCameraDevice:UIImagePickerControllerCameraDeviceFront];
}
}
// Show the camera UI and View Finder.
[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
}
Please check the attachment
Image is here
one of the solution is applying scaling trasnformation - here on stack maybe it will help
I don't see why you are doing these 3 things:
[self.navigationController setNavigationBarHidden:YES];
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];
[self.camPicker.view setUserInteractionEnabled:YES];
Or for that matter why you are caching the instance of UIImagePickerController (this may cause significantly higher idle memory usage for your application compared to discarding the image picker controller between uses).
Does it work better if you don't do these things?

iPad2 Camera code same as iPhone4?

I am making an app for the iPad and want to be able to use the iPad 2 camera if available. Is the code to load the iPad camera the same as for the iPhone 4? I have this same code working on the iPhone version of this app, but do not have an iPad 2 to test with and simulator can't help me with the camera. Below is what I have to determine if camera is available and then to load camera or load library in popup
Basically I just need to know if the line below is supported by the iPad 2 camera or do I need to use something else?
[self presentModalViewController:imagePickerController animated:YES];
I want camera to be full screen and not in a popup.
- (IBAction) takePhoto:(id)sender {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
imagePickerController = [[UIImagePickerController alloc] init];
[imagePickerController setDelegate:self];
[imagePickerController setSourceType:UIImagePickerControllerSourceTypeCamera];
imageView.contentMode = UIViewContentModeScaleAspectFit;
[self presentModalViewController:imagePickerController animated:YES];
} else {
imagePickerController = [[UIImagePickerController alloc] init];
[imagePickerController setDelegate:self];
[imagePickerController setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
imageView.contentMode = UIViewContentModeScaleAspectFit;
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:imagePickerController];
[popover setDelegate:self];
[popover presentPopoverFromBarButtonItem:sender
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}
}
Yes this works, for sure if self is a UINavigationController. I know this because I do the same in my app. I'm not sure for other UIViewControllers, but it stands to reason that it will also work.