0

I am presenting UIImagePickerController from the view controller. Its getting the following crash report only in iOS 6 but not getting in iOS 7.

*** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'preferredInterfaceOrientationForPresentation must return a supported interface orientation!'

I am getting this crash only when presenting the UIImagePickerController.

My app supports Portrait orientation so i am using the following code

-(BOOL)shouldAutorotate {

    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {

    if(UIInterfaceOrientationIsPortrait(toInterfaceOrientation))
        return YES;

    return NO;
}

-(NSUInteger)supportedInterfaceOrientations {

    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {

    return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {

    return self.interfaceOrientation;
}

But only one page will support both portrait and landscape orientation so i enabled all orientations in info.plist

enter image description here

can any one pls help me that how to fix this crash.

Surfer
  • 1,370
  • 3
  • 19
  • 34
  • remove all the methods and through project settings you can .... – Arun Jul 30 '14 at 05:06
  • check this twohttp://stackoverflow.com/questions/12690963/preferredinterfaceorientationforpresentation-must-return-a-supported-interface-o – Mohit Jul 30 '14 at 05:38
  • check this also http://www.scott-sherwood.com/tutorial/ios-6-uiapplicationinvalidinterfaceorientation-exception/ – Mohit Jul 30 '14 at 05:39
  • sorry guys it doesnt helps any more. still crash occurs in iOS6.can you pls help me to fix this – Surfer Jul 31 '14 at 12:39

1 Answers1

1

You can check this Stack overflow question This may help you. i had same same issue in a previous project and this helped out me. try it

Community
  • 1
  • 1
Viper
  • 1,408
  • 9
  • 13