I am getting this error in a universal iOS 6.0 sdk app:

2013-02-03 23:41:57.078 scrappling[20350:c07] *** Terminating app due to
uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason:
'preferredInterfaceOrientationForPresentation must return a supported
interface orientation!'

This occurs in the iPad 6.0 simulator, simulating a non-retina ipad.

The initial view controller of the app is a UITabViewController subclass.
The storyboard for the app looks like this:

http://dl.dropbox.com/u/597030/debugging/Screen%20Shot%202013-02-03%20at%2011.50.49%20PM.png

This is how I reproduce the crash:

1)select an item in the master tableviewcontroller which calls [self
presentMoviePlayerViewControllerAnimated:_playerVC];
2)_playerVC is a MPMoviePlayerViewController subclass that presents a video
fullscreen.
3)the moment I tap "Done" on the video, Cocoa Touch fires
[MMATabBarController preferredInterfaceOrientationForPresentation] and
returns UIInterfaceOrientationMaskLandscape:

MMATabBarController.m:

~snip~
-(BOOL)shouldAutorotate
{
  return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{

  if([[UIDevice currentDevice] userInterfaceIdiom] ==
UIUserInterfaceIdiomPhone)
  {
    return UIInterfaceOrientationMaskPortrait;
  }
  else
  {
    return UIInterfaceOrientationMaskLandscape;
  }
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{

//  return UIInterfaceOrientationMaskAll;
  if([[UIDevice currentDevice] userInterfaceIdiom] ==
UIUserInterfaceIdiomPhone)
  {
    return UIInterfaceOrientationMaskPortrait;
  }
  else
  {
    return UIInterfaceOrientationMaskLandscape;
  }
}
~snip~

4)I've confirmed UIInterfaceOrientationMaskLandscape gets returned from
-preferredInterfaceOrientationForPresentation
5)I've confirmed UIInterfaceOrientationMaskLandscape gets returned from
-supportedInterfaceOrientations

6)Crash!


~~~~~~~~


What I don't understand is why this message is occurring because I have
confirmed that at startup [MMATabBarController
-supportedInterfaceOrientations] returns
UIInterfaceOrientationMaskLandscape. Also my info.plist looks like this:

  <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>

Attempted workarounds:

1)I had -preferredInterfaceOrientationForPresentation return
UIInterfaceOrientationMaskAll.

2) I added the application:supportedInterfaceOrientationsForWindow:
delegate method to the app delegate. I've confirmed that this gets fired
and UIInterfaceOrientationMaskLandscape gets returned:


-(NSUInteger)application:(UIApplication *)application
supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
  if([[UIDevice currentDevice] userInterfaceIdiom] ==
UIUserInterfaceIdiomPhone)
  {
    return UIInterfaceOrientationMaskPortrait;
  }
  else
  {
    return UIInterfaceOrientationMaskLandscape;
  }
}

3) I subclassed UINavigationController and I've confirmed that on app
startup UIInterfaceOrientationMaskLandscape is returned. The
UINavigationController looks like this:

MMANavigationController.m:

~snip~
-(BOOL)shouldAutorotate
{
  return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{

  if([[UIDevice currentDevice] userInterfaceIdiom] ==
UIUserInterfaceIdiomPhone)
  {
    return UIInterfaceOrientationMaskPortrait;
  }
  else
  {
    return UIInterfaceOrientationMaskLandscape;
  }
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{

//  return UIInterfaceOrientationMaskAll;
  if([[UIDevice currentDevice] userInterfaceIdiom] ==
UIUserInterfaceIdiomPhone)
  {
    return UIInterfaceOrientationMaskPortrait;
  }
  else
  {
    return UIInterfaceOrientationMaskLandscape;
  }
}
~snip~

Any suggestions on what may be going wrong?

Michael
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to