0

I am using UIImagePickerviewController to open the photo library through the below attached code... after called bit lines of code. The application was crashed... Its working fine in ios5

UIImagePickerController* content = [[UIImagePickerController alloc] init];
content.delegate = self;
content.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
[self presentModalViewController:content animated:YES];
[content release];

Is anything wrong with this code?

CAMOBAP
  • 5,523
  • 8
  • 58
  • 93
StalinPusparaj
  • 53
  • 2
  • 11
  • I had this issue a few days ago as well, let me check how I fixed it. – Myth1c Nov 08 '12 at 11:03
  • I think it had something to do with autolayout. Do you have autolayout enabled on the view where you are putting the uiimagepicker on? – Myth1c Nov 08 '12 at 11:06
  • Oh, and shouldAutoRotateToInterfaceOrientation is depricated in ios6: Override the supportedInterfaceOrientations and preferredInterfaceOrientationForPresentation methods instead. – Myth1c Nov 08 '12 at 11:08
  • i have followed as you given the procedure but nothing will happen my code is here instead of using shouldAutorotateToInterfaceOrientation: -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAll; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationLandscapeRight; } – StalinPusparaj Nov 08 '12 at 11:29

3 Answers3

0

Check Crash on presenting UIImagePickerController under ios6 You will get everything you need to make UIImagePickerviewController working on iOS 6.0.

Community
  • 1
  • 1
Paresh Masani
  • 7,474
  • 12
  • 73
  • 139
0
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
  popover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
  [popover presentPopoverFromRect:cameraButton.frame inView:self.view  
  permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
else{
 [self presentModalViewController:imagePicker animated:YES];
}
hardik hadwani
  • 556
  • 6
  • 24
0

I had the same issue. Because the UIImagePicker shows on portrait mode. I fixed it by subclassing the UIImagePicker and implementing the shouldAutorotate method like:

- (BOOL)shouldAutorotate
{
    return NO;
}

I have created instance of my subclassed imagePicker instead of UIImagePicker, everything worked fine. Hope this will help you.

Midhun MP
  • 103,496
  • 31
  • 153
  • 200
  • finally i got solved this orientation issue and crashing the app through subclass of UIImagePicker and i had included following method - (BOOL)shouldAutorotate { return NO; } – StalinPusparaj Nov 09 '12 at 15:47
  • @StalinPusparaj: i din't get the +1 :) if it solved your issue. Please accept the answer :) – Midhun MP Nov 10 '12 at 06:47
  • in SO we usually say +1 when we put a up vote :) That's why I thought. Ok dude. Anyway thanks for your comment :) – Midhun MP Nov 16 '12 at 14:12
  • Hi It doesn't work for me on ios6. Any idea how can I do it? It still rotates the picker – Dejell Jan 21 '13 at 18:14