Search code examples
iphoneipadphoto-gallerylandscape-portrait

Photogallary is appear in portrait mode even though iPhone is in landscape mode


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....


Solution

  • 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.!!