0
votes

Hi all I set the device in landscape mode, in that mode while I press the "photo gallery" button the gallery is open in the portrait mode and after choose the pic from gallery it will come back to landscape mode. I want to open the gallery in landscape mode when i working in landscape mode.

I used this code to open photogallery

- (void)imagesFromGallery{
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
{
    if(!popover) 
    {
        popover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
    }

    [popover presentPopoverFromRect:CGRectMake(500, 620, 0, 0)
                             inView:self.view
           permittedArrowDirections:UIPopoverArrowDirectionUp 
                           animated:YES];
}
else 
{
    [self presentModalViewController:imagePicker animated:YES];
}   }

Thanks in advance....

2
Photo gallery always opens in the Portrait mode, you can not do anything to change it into Landscape mode.except if you fetch all the images and make a view of your own. That is going to be very tedious! - Tripti Kumar
Before posting questions like this, PLEASE READ THE DOCS. Apple provide all the reference for a reason. It would have taken less time to search the docs than to post this question. To quote the documentation "Important The UIImagePickerController class supports portrait mode only." - Nick Bull

2 Answers

2
votes

Instead of Presenting it

 [self presentModalViewController:imagePicker animated:YES];

Add the imagePickerView to the self.view and set the frame of the imagePicker

[self.view addSubview:imagePicker.view];

Hope it Will Work for You.!!

0
votes

The above answer works fine. But once you loaded the image gallery, scrolling the view and selecting the folder is a problem.

Subclassing the UIImagepicker is the right option. Just create a class which is subclass of UIImagepicker and add the below method.

-(NSUInteger)supportedInterfaceOrientations
{

    return UIInterfaceOrientationMaskAll;
}

Rest, asusual alloc this viewcontroller and present.