Any idea why this look doesn't spin?

I am working on a photo view controller to display some photos in portrait and landscape views. What I did is edit the orientation -(BOOL)shouldAutorotateToInterfaceOrientation using the code below, but when testing in xcode (hardware menu> Turn right) the view does not rotate in landscape orientation. Is there something wrong with what I did?

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight); } 

The view controller is part of a tabbed iphone application and this view is not the root view: is this a problem?

+4
source share
7 answers

The method you want to override shouldAutorotateToInterfaceOrientation . Your method signature lacks Orientation at the end.

0
source

Also check supported orientations. For Xcode 4 (Project-> Summary (Tab) → Orientation of a supported device → Desired orientation).

+1
source

My first idea would be to simply return true; to make sure that there are no problems with the parameters passed in / your comparison (this is good for me, but you never know).

Further it would be if this view is not directly tied to a window (or another top-level object if you use xib), you might also need to return true in any parent views. For testing, you can simply overwrite:

 -(BOOL)shouldAutorotateToInterfaceOrientation:(UIIinterfaceOrientation)interfaceOrientation { return true; } 

for all views (controllers) in the tree.

+1
source

it can only be a typo, but its not a UIIinterfaceOrientation , its UIInterfaceOrientation

+1
source

Make sure that the ViewController in which you implement this method is the rootViewController window. Also, the use of return (interfaceOrientation != UIIinterfaceOrientationPortraitUpsideDown) better read .;)

Is -shouldAutorotateToInterfaceOrientation called? Try writing something to this method ...

0
source

Your search is in the wrong place: in your RootViewController.m file RootViewController.m find the following code:

 #elif GAME_AUTOROTATION == kGameAutorotationUIViewController // //lots of useless comments // return (UIInterfaceOrientationIsPortrait(interfaceOrientation) ); //THIS LINE HERE 

the line that says return (UIInterface ... Portrait) is the line that defines the capabilities of your application. You can change this to anything to allow you to fully rotate, to keep it in a certain orientation or whatever you want ...

also in this

  -(BOOL)shouldAutorotateToInterfaceOrientation:(UIIinterfaceOrientation)interfaceOrientation { /* return (interfaceOrientation == UIIinterfaceOrientationPortrait || interfaceOrientation == UIIinterfaceOrientationLandscapeLeft || interfaceOrientation == UIIinterfaceOrientationLandscapeRight); */ //GET RID OF ALL THIS CRAP return true; //do this instead, and if this doesn't work, try return YES; } 
0
source

I'm not sure if this is a type error or a version difference, in my last Xcode method looks like this:

- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) toInterfaceOrientation

and it works well, do you skip the "before" argument?

0
source

All Articles