2011-11-24 36 views

回答

5

這是正確的 - 使用此私有方法時,您的應用將被拒絕。我們已經做到了,我們已經被拒絕了(並且我們找到了解決方法)。

+0

任何建議如何設置設備方向,而不會拒絕應用程序? –

+1

@ПавелОганесян:沒有,你不應該改變方向,因爲這將是意想不到的行爲。但是,您可以限制您的應用或當前活動的UIViewController可以旋轉到的方向。請參閱[文檔](http://developer.apple.com/library/ios/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instm/UIViewController/shouldAutorotateToInterfaceOrientation :)。 – DarkDust

+1

@darkDust我已經知道了 - '(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation',它的理解和使用相當簡單。我的問題是如何在導航堆棧中的某些視圖在別人修復時進行旋轉。有些控制器只是阻止他人的旋轉而不考慮其設置。 :)也許,我應該創建另一個問題並在那裏討論它。 –

1

目前(iOS 5中)的定義是:

@property (nonatomic, readonly) UIDeviceOrientation orientation 

所以即使有一個setter(setOrientation:.orientation =),這將是私有API作爲官方文件說,它不存在。而使用私有API會讓你被拒絕。

1

如果沒有記錄方法,請不要使用它。使用未記錄的方法將導致拒絕。這與檢查Apple文檔一樣簡單。

在這種情況下,文檔狀態:

@property (nonatomic, readonly) UIDeviceOrientation orientation 
2

的方法是存在的,給你關於設備的物理方位信息,無編碼的數量將改變這種物理方向。它是根據陀螺儀/加速度計設置的,它告訴設備它的方向是沒有意義的。

如果你想改變界面的方向,那麼你應該看看的UIViewController回調,允許您定義:

interfaceOrientation property 
– shouldAutorotateToInterfaceOrientation: 
+ attemptRotationToDeviceOrientation 
– rotatingHeaderView 
– rotatingFooterView 
– willRotateToInterfaceOrientation:duration: 
– willAnimateRotationToInterfaceOrientation:duration: 
– didRotateFromInterfaceOrientation: 
-1

使用此:

  • (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { 回報UIInterfaceOrientationPortrait; }
+0

這將是很好的知道*爲什麼*應該使用這個 – anatolyg