سؤال

new to iPhone and having difficulty with making an iPhone app only support portrait.

I'm using storyboarding and targeting iOS5+.

I've had a good look on here, and the suggestions for other people haven't worked for me.

I've tried implementing

 -(BOOL)shouldAutorotateToInterfaceOrientation:UIInterfaceOrientation)interfaceOrientation       
 {
      return NO;
 }

on view controllers, and changing my info.plist to

<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>

but no joy. In the storyboard I've also chosen portrait in the attributes editor.

Any more ideas?

Many thanks, Jordan

هل كانت مفيدة؟

المحلول

Have you tried using the orientation buttons that show up when selecting your target on xCode4?

enter image description here

نصائح أخرى

you can use below options for the same method. No need to change in plist file.

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

here I use UIInterfaceOrientationPortrait and UIInterfaceOrientationPortraitUpsideDown with or condition, using this I allow application rotate only in portrait mode.

If you want your application can rotate in all view sides then return YES in above method.return NO indicate you want view don't rotate anyway.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top