3

I've heard that using of [UIDevice setOrientation:] can be the reason to app rejection in Appstore. Is there any proofed info about it?

Machavity
  • 30,841
  • 27
  • 92
  • 100
Pavel Oganesyan
  • 6,774
  • 4
  • 46
  • 84

5 Answers5

5

That is correct - your app will get rejected when using this private method. We have done it, we have gotten rejected (and we found workarounds).

Till
  • 27,559
  • 13
  • 88
  • 122
  • Any suggestions how to set device orientation without getting app rejected? – Pavel Oganesyan Nov 24 '11 at 13:09
  • 1
    @Павел Оганесян: There is none, and you shouldn't change the orientation anyway as that would be unexpected behavior. You can, however, limit to which orientations your app or the current active UIViewController may rotate to. See [the docs](http://developer.apple.com/library/ios/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instm/UIViewController/shouldAutorotateToInterfaceOrientation:). – DarkDust Nov 24 '11 at 13:18
  • 1
    @darkDust I already got it about - `(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation` and it is rather simple to understand and use. My problem is how to make some views in navigation stack rotate when others are fixed. Some controllers just block rotation of others with no respect to their settings. :) Probably, I should create another question and discuss it there. – Pavel Oganesyan Nov 24 '11 at 13:23
2

The method is there to give you information about the physical orientation of the device, no amount of coding will change that physical orientation. It is set depending on the gyros/accelerometers it would make no sense for you to tell the device what its orientation is.

If you want to change the interface orientation then you should look into the UIViewController callbacks which allow you to define that:

  interfaceOrientation  property
– shouldAutorotateToInterfaceOrientation:
+ attemptRotationToDeviceOrientation
– rotatingHeaderView
– rotatingFooterView
– willRotateToInterfaceOrientation:duration:
– willAnimateRotationToInterfaceOrientation:duration:
– didRotateFromInterfaceOrientation:
jbat100
  • 16,757
  • 4
  • 45
  • 70
1

The current (iOS 5) definition is:

@property (nonatomic, readonly) UIDeviceOrientation orientation

So even if there is a setter (setOrientation: or .orientation =) it would be private API as the official documentation says it doesn't exist. And using private API will get you rejected.

DarkDust
  • 90,870
  • 19
  • 190
  • 224
1

If a method is not documented, don't use it. Using undocumented methods will result in rejection. It is just as simple as checking the Apple documentation.

In this case the documentation states:

@property (nonatomic, readonly) UIDeviceOrientation orientation
Filip Radelic
  • 26,607
  • 8
  • 71
  • 97
zaph
  • 111,848
  • 21
  • 189
  • 228
-1

Use this:

  • (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{ return UIInterfaceOrientationPortrait; }
moloradio
  • 13
  • 5