2

i am developing iPad app which supports Landscape only

What i want to do is, i want to open photos library on button click. Here is my code snippet,

UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.modalPresentationStyle = UIModalPresentationCurrentContext;

when i wrote this it doesn't open photos library :( I don't know where i am doing mistake

Please help and thanks in adavance.

Krunal Lathia
  • 75
  • 2
  • 14

1 Answers1

0

Try this:

UIImagePickerController *picker=[[UIImagePickerController alloc]init];
picker.delegate=self;
picker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;

if([[[UIDevice currentDevice] systemVersion] floatValue]>=8.0)
{
    [[NSOperationQueue mainQueue] addOperationWithBlock:^{
        [self presentViewController:picker animated:NO completion:nil];
    }];
}else{
    [self presentViewController:picker animated:YES completion:nil];
}
Pang
  • 9,564
  • 146
  • 81
  • 122
ggg_1120
  • 398
  • 2
  • 19
  • It crashes and shows: `UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'` – Krunal Lathia Jun 23 '15 at 09:48