How hide bottom toolbar - ios

I have a problem showing the album a toolbar with the following buttons, previous and the new one appears in the bottom view. How can you hide this toolbar?
Thanks in advance.
Album photo image
UIImagePickerController *controller = [[UIImagePickerController alloc] init];
controller.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
controller.allowsEditing = YES;
controller.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType: UIImagePickerControllerSourceTypePhotoLibrary];
controller.delegate = self;
[self.navigationController presentViewController: controller animated: YES completion: nil];

If you want to hide the toolbar you can use the following code . Here the toolBarName is the name of your toolbar.
toolBarName.hidden=YES;

Include this in the viewWillAppear function:
self.navigationController?.isToolbarHidden = true
However, this is a Swift solution.

Use this code.Hope it helps..
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init] ;
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
imagePickerController.delegate = self;
imagePickerController.allowsEditing = FALSE;
[imagePickerController setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[self presentViewController:imagePickerController animated:YES completion:nil];
}

Related

iOS 9 UIImagePickerControllerSourceTypePhotoLibrary crash when orientation allow only Landscape

I had create app which only support Landscape orientation, whenever I called UIImagePickerControllerSourceTypeCamera to take picture using camera is worked, but when I called UIImagePickerControllerSourceTypePhotoLibrary it crashed.
I had tried using method shouldAutoRotate() to allow portrait but still not working. Any solution for this problem ?
As you are getting this error on iPad
Try the below code and use UIModalPresentationStyle for this purpose :-
self.imagepicker.modalPresentationStyle = UIModalPresentationStyle.Popover
let popover = self.imagepicker.popoverPresentationController
self.imagepicker.preferredContentSize = CGSizeMake(400 ,400)
popover!.sourceView = self.view
popover!.sourceRect = CGRectMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds),0,0)
popover!.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
self.presentViewController(self.imagepicker, animated: true, completion: nil)
This is in Swift, I hope you can covert to objective-c easily.
I hope this helps.
Set modalPresentationStyle of your imagePickerController to UIModalPresentationCurrentContext and then present it. Something like,
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
Put Presentviewcontroller code in NSOperationQueue
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
self.presentViewController(self.imagepicker, animated: true, completion: nil)
}];
I give you the solution
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.wantsFullScreenLayout = YES;
UIPopoverController *imagePopover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
[imagePopover setDelegate:self];
[imagePopover setPopoverContentSize:CGSizeMake(320, 500) animated:NO]; //set your content size
[imagePopover presentPopoverFromRect:button.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES]; //I give presentPopoverFromRect as button frame.Change here what you want
}

Can't present imagepicker immediately

I have a Tab bar controller, when I tap the third tab bar button I present a UIViewcontroller. In the viewWillAppear of this vc I'm presenting a UIImagepickerController that works fine. The problem is I can't display it on the screen immediately when I open the view. First the vc shows up and after 0.4-0.5 sec the image picker. So I would like to present the image picker first and present the vc after the user took an image. I tried to call the picker from viewDidLoad and viewWillAppear too, but nothing changed.
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
if (imagePickerWasPresented == NO)
{
imagePickerWasPresented = YES;
self.imagePicker = [[UIImagePickerController alloc] init];
self.imagePicker.delegate = self;
self.imagePicker.allowsEditing = YES;
self.imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.imagePicker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeImage];
[self presentViewController:self.imagePicker animated:NO completion:nil];
}
}
Am I calling it in a wrong place?
I had the same problem - instead of calling the VC and then the UIImagePicker, call the UIImagePicker directly.
When you are done taking a picture/video:
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {}
you will go to this standard delegate method, call the VC from here. This way you will immediately go to the ImagePicker and only have a transition would you choose to do something with the taken content afterwards which is less frustrating/ugly.
No, your calling it in an okay place, that's just how iOS does it; if you present multiple modals on top of each other, one gets presented after the other, including the animation. A solution that would work for your problem is to present a UINavigationController instead of your UIViewController. Set the navigation controller up to have ViewController as the root viewcontroller, but also push your imagepickercontroller onto the stack. Present this navigationcontroller and it should go right to your imagepickercontroller. Otherwise, try presenting both uiviewcontroller and imagepickercontroller with animation set to NO and see if that works.
try this to see how close that gets you then adapt to your needs. when i gave it a quick test it seemed to do what you were asking.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] ;
UIViewController * vc = [[UIViewController alloc] init];
vc.view.backgroundColor = [UIColor whiteColor];
UINavigationController * navigationController = [[UINavigationController alloc] init];
[navigationController pushViewController:vc animated:NO];
UITabBarController * tabBarController = [[UITabBarController alloc] init];
NSArray* controllers = [NSArray arrayWithObjects:navigationController, nil];
tabBarController.viewControllers = controllers;
tabBarController.delegate = self;
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes = [NSArray arrayWithObjects:
(NSString *) kUTTypeImage,
nil];
imagePicker.allowsEditing = NO;
self.window.rootViewController = tabBarController;
[self.window makeKeyAndVisible];
[vc presentViewController:imagePicker animated:NO completion:nil];
return YES;
}
UIImage as a PopOver
Gallery mode:
BOOL hasGallery = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary];
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = hasGalleryt ? UIImagePickerControllerSourceTypePhotoLibrary : UIImagePickerControllerSourceTypePhotoLibrary;
if (self.popoverController != nil)
{
[self.popoverController dismissPopoverAnimated:YES];
self.popoverController=nil;
}
self.popoverController = [[UIPopoverController alloc] initWithContentViewController:picker];
CGRect popoverRect = [self.view convertRect:[self.imageView frame]
fromView:[self.imageView superview]];
popoverRect.size.width = MIN(popoverRect.size.width, 300) ;
popoverRect.origin.x = popoverRect.origin.x;
[self.popoverController
presentPopoverFromRect:popoverRect
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
Camera mode:
BOOL hasCamera = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = hasCamera ? UIImagePickerControllerSourceTypeCamera : UIImagePickerControllerSourceTypePhotoLibrary;
if (self.popoverController != nil)
{
[self.popoverController dismissPopoverAnimated:YES];
self.popoverController = nil;
}
self.popoverController = [[UIPopoverController alloc] initWithContentViewController:picker];
CGRect popoverRect = [self.view convertRect:[self.imageView frame]
fromView:[self.imageView superview]];
popoverRect.size.width = MIN(popoverRect.size.width, 300) ;
popoverRect.origin.x = popoverRect.origin.x;
[self.popoverController
presentPopoverFromRect:popoverRect
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
Remember to give to the .h File #interface the delegates, like this:
#interface the UIViewController: UIViewController <UIPopoverControllerDelegate, UIImagePickerControllerDelegate>

Using .xib file as the custom camera overlayview

I created a CameraOverlayViewController with .xib file to implement a customized camera overlayView with. The overlayView is just a transparent background with a button to select photo from the photoLibrary and it loads successfully in the mainViewController with the following code:
CameraOverlayViewController* overlay = [[CameraOverlayViewController alloc] initWithNibName:#"CameraOverlayViewController" bundle:nil];
cameraPicker.cameraOverlayView = overlay.view;
However, nothing happens when I pressed the button on the cameraOverlayView. No error messages, nothing. Does anyone know what's going on here? Below is my code in the CameraOverlayViewController file:
- (IBAction)select:(UIButton *)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
[self dismissViewControllerAnimated:YES completion:^{
[self presentViewController:picker
animated:YES completion:nil];
}];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:NULL];
NSLog(#"Just work alrdy!!!");
}
Thanks in advance!
Try This..
-(IBAction)select:(UIButton *)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self dismissViewControllerAnimated:YES completion:^{
[self presentViewController:picker
animated:YES completion:nil]; ////////check this is called??????
}];
}

UIImagePickerController issue when Present

i am really frustrated about this issue...when i try to present UIImagePickerController..it shows the number of images..but not those all images.Can anyone help..
UIImagePickerController *imgPickerController = [[UIImagePickerController alloc]init];
imgPickerController.delegate=self;
imgPickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:imgPickerController animated:YES completion:nil];
Can you like this?
UIImagePickerController *image_picker = [UIImagePickerController new];
image_picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
image_picker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
image_picker.delegate = self;
[self presentModalViewController:image_picker animated:YES];
i have added new category file for UIView..that was the issue..now i dont have that issue when i remove that category file from my project...

how to open an image picker on ipad just in code

How can I create the image picker in code?
I use iOS 6.0 , with ARC, for ipad.
I would like to able to select the picture and somehow get UIImage of the selected image.
i did add delegates:
enter code here
in the viewDidLoad method did
enter code hereimagePicker = [[UIImagePickerController alloc] init];
and in the button method for click i have put
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:imagePicker animated:YES];
the crash happens in
[self presentModalViewController:imagePicker animated:YES];
There are some tutorials here http://www.raywenderlich.com/130/how-to-write-a-custom-image-picker-like-uiimagepicker and http://mobileorchard.com/ios-advanced-programming-the-image-picker/ that might help you
I have similar code in one of my projects, but I had
[self presentViewController:imagePicker animated:YES completion:nil];
instead of
[self presentModalViewController:imagePicker animated:YES];
Try that and see if it works. Note the presentViewController rather than presentModalViewController.
Add a property in .h
#property (strong) UIPopoverController *pop;
In you r .m file under your button implimentation add something like:
if (self.pop) {
[self.pop dismissPopoverAnimated:YES];
}
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePickerController.delegate = self;
imagePickerController.allowsEditing = YES; //if you want to edit the image
self.pop=[[UIPopoverController alloc] initWithContentViewController:imagePickerController];
//choose the direction of the arrow for the popover
[self.pop presentPopoverFromRect:((UIButton *)sender).bounds inView:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
}
Make sure you have your <UIPopoverControllerDelegate> delegate set in .h

Resources