-1

I want to have my app always in portrait mode facing up. That means that if the device it tipped to passed perpendicular to the floor and is starting to face the floor, it will readjust so it functions like it is in portrait mode facing upward. The same with if the device starts to be portrait upside-down, it will be portrait facing up (tilted upward. I have placed this in my apps delegate

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

under the -(BOOL) application did finishLaunching etc. but I need to know what I need to put into the delegate so throughout the app the above is always true.

Anyone help.

user1114881
  • 731
  • 1
  • 12
  • 25

2 Answers2

0

You can set this in your project's deployment info in Xcode. enter image description here

I think you also need to implement shouldAutorotate and supportedInterfaceOrientations in your UIViewControllers. This Apple reference doc should help: UIViewController Class Reference.

Also, here's a similar question and answer.

Community
  • 1
  • 1
gstroup
  • 1,064
  • 8
  • 16
  • I have only portrait checked in my info.plist however when the device is held upside down it does NOT rotate so it is right side up protrait(home button at the top). – user1114881 Oct 03 '13 at 19:49
  • Sounds like you need to also check "upside down". Then your app will rotate both ways in portrait mode, but never rotate to landscape mode. – gstroup Oct 03 '13 at 20:47
  • I have now checked also upside down. But it is not rotating. Do I need to comment out all autorotating code in the rest of the app. Like in the app delegate and in each of the controller views I want to rotate? – user1114881 Oct 03 '13 at 21:31
0

You specifying all required orientations in your Info.plist file as Array with a key UISupportedInterfaceOrientations Limit the list of supported orientation to the orientation that you want. beginGeneratingDeviceOrientationNotifications is very specific method that required for a unique use-cases but not for general orientation handling. Here is some of examples where beginGeneratingDeviceOrientationNotifications could be useful, but it is definitely not your case - How to handle autorotation in AVCaptureVideoPreviewLayer?

Community
  • 1
  • 1
Nikita Leonov
  • 5,684
  • 31
  • 37