I am opening photo library from a button in UIPopover, but photo library is displayed behind the popover.
I am presenting popover as follow.
[self.commentsPopover presentPopoverFromRect:rectInSuperview inView:self.superview permittedArrowDirections:UIPopoverArrowDirectionLeft | UIPopoverArrowDirectionRight animated:YES];
self.commentsPopover is UIPopoverController.
After popover is displayed, I am opening photo library against button in popover.
self.attachmentPicker = [[ELCImagePickerController alloc] initImagePicker];
self.attachmentPicker.maximumImagesCount = MAX_ATTACHMENT_COUNT;
self.attachmentPicker.returnsOriginalImage = NO; //Only return the fullScreenImage, not the fullResolutionImage
self.attachmentPicker.imagePickerDelegate = self;
self.attachmentsView.delegate = self;
self.attachmentPicker.modalInPopover=YES;
self.attachmentPicker.modalPresentationStyle = UIModalPresentationFormSheet;
[MKGlobals presentViewController:self.attachmentPicker animated:YES completion:^{
self.attachmentPicker = nil;
}];
This displays photo library behind the popover.
Follow image describes scenario.
This code is working fine in iOS < 8.x.
Any help will be appreciated.
Related
I am working on an app using iOS 7. Sometimes I face a problem in iOS 6 device when i open the camera. It freezes on camera shutter. Although I set ARC to YES. I couldn't understand where is the problem?
I used the code for this
self.cameraUI = [[UIImagePickerController alloc] init];
self.cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
self.cameraUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
self.cameraUI.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
self.cameraUI.navigationBarHidden = YES;
self.cameraUI.showsCameraControls = NO;
self.cameraUI.wantsFullScreenLayout = YES;
self.cameraUI.delegate = self;
[self.cameraView addSubview:self.cameraUI.view];
You shouldn't be doing addSubview: to a UIImagePickerController's view. Instead it is recommended to present the UIImagePickerController and implement its delegates to get the selected image.
From Apple docs for How to use UIImagePickerController?,
Present the user interface. On iPhone or iPod touch, do this modally (full-screen) by calling the presentViewController:animated:completion: method of the currently active view controller, passing your configured image picker controller as the new view controller.
This is how you can present it from your controller,
[viewcontrollerObj presentViewController:self.cameraUI animated:YES completion:nil];
Hope that helps!
In my iOS app i present standerd controllers MFMessageComposeViewController and UIImagePickerController.
But they both presenting with strange navigation bar.
How can i fix this problem?
UPD code for presenting controllers
UIImagePickerController:
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = sourceType;
cameraUI.allowsEditing = YES;
cameraUI.delegate = self;
[self presentViewController:cameraUI animated:YES completion:nil];
MFMessageComposeViewController:
MFMessageComposeViewController *messageViewController = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText]) {
messageViewController.view.backgroundColor = [UIColor whiteColor];
messageViewController.messageComposeDelegate = self;
recipient= [NSStringMask maskString:recipient withPattern:#"\\+(\\d{1}) \\((\\d{3})\\) (\\d{3})-(\\d{2})-(\\d{2})"];
messageViewController.recipients = #[recipient];
messageViewController.body = body;
[self presentViewController:messageViewController animated:YES completion:nil];
}
In iOS 7, the status bar and the navigation is translucent by default. To make the view act 'normal' like in iOS 6. you need to add this to the controller you are presenting.
if ([self respondsToSelector:#selector(edgesForExtendedLayout)])
self.edgesForExtendedLayout = UIRectEdgeNone;
If you want to read up more about changes in views. Check out this post. I find it a nice quick overview whats changed.
http://www.brianjcoleman.com/ios7-weve-got-a-problem/
See this question. I used the second answer, though I suspect the first would work for me also.
I am using the UIImagePicker to select a photo from the users photo library.
Here is my setup:
MenuViewController (UINavigationController class) that has a tweet button.
Click the tweet button, it presents modally a custom tweet composer.
Select the "Camera Roll" button and I call UIPickerView which is also presented modally.
When you select camera roll (or any album) I get this error:
2013-08-03 02:25:41.842 appName[2145:f803] nested push animation can result in corrupted navigation bar
and my custom back button now looks like this:
instead of:
Here is the code that displays the tweet composer:
- (IBAction)tweetButtonPressed:(id)sender {
KBTweetComposer *vc = [self.storyboard instantiateViewControllerWithIdentifier:#"new_tweet"];
vc.defaultText = #"";
[self presentViewController:vc animated:YES completion:nil];
}
Here is how I'm presenting the picker view:
- (void)photosButtonPressed:(id)sender {
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:nil];
}
I am using storyboards, but I am not using segues, just as a side note. I have found quite a few different people on StackOverflow who have the same error but a completely different circumstance.
It may be related to Presenting a UIViewController that then presents another UINavigationController (The UIImagePicker by default has a Nav Controller) in addition to the original.
How can I get around this? Any help would be great, thanks!
I have looking for a complete tutorial on google and stack of a complete example on using the UIImagePicker to get a picture from the camera and a picture from the library or camera roll on the iPad 2.
I have found code snippets saying just add the PopOverController in, but have not been able to implement it successfully.
thanks in advance.
This worked for me.
I do it like this I detect if iPhone or iPad and in the popover where it says (self.album.bounds) is just were you want the popover arrow to appear in this case self.album is the button that fires the below action
-(IBAction)selectPicture:(id)sender {
NSLog(#"Image is not set");
// Create image picker controller
thePicker = [[UIImagePickerController alloc] init];
// Set source to the camer roll;
thePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
// Delegate to self
thePicker.delegate = self;
//Allow editing of image NO
thePicker.allowsEditing = NO;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
[self presentModalViewController:thePicker animated:YES];
}
else{
popover = [[UIPopoverController alloc]initWithContentViewController:thePicker];
[popover presentPopoverFromRect:self.album.bounds inView:self.album permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
popover = popover;
}
}
I have been beating my head on this for a few hours. I have some sample code (using a UINavigationController) when the view loads the camera roll will be presented. However, when I try to incorporate the same code into my app, which has a tabBarController, I get a blank modal UIImagePickerController. I didn't track down what I am doing wrong.
// bring up image picker
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeSavedPhotosAlbum]) {
NSLog(#"UIImagePickerControllerSourceTypePhotoLibrary available");
UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
ipc.delegate = self;
ipc.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
ipc.allowsEditing = YES;
[self.tabBarController presentModalViewController:ipc animated:YES];
[ipc release];
}
Any insight would be appreciated.
Not sure what has changed, but this is possible by calling presentViewController from your tabBarController. This is the standard now and ensures your camera or image picker always gets presented as a full screen modal view.
For reference: presentViewController