2015-06-21 88 views
1

我想通過點擊一個按鈕來使屏幕旋轉。但是,由於佈局複雜,我使用sizeClass,我不打算通過設置視圖的變換來實現它。所以我可以調用系統的方法。如果是的話,以及如何?我可以調用系統的自動旋轉方法嗎?

+0

那麼你可以覆蓋,但用戶仍然必須打開設備,並手動觸發它,如果你不想讓它變得像超級錯綜複雜。 – LinusGeffarth

+0

@LinusG。我知道了!所以最好的解決方案是設置視圖的變換? – elephant

+0

你是什麼意思? – LinusGeffarth

回答

0

試試這個:

if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) 
{ 
    objc_msgSend([UIDevice currentDevice], @selector(setOrientation:), UIInterfaceOrientationPortrait); 
} 

然而,這是一個私人的API。

+0

所以我必須設置視圖的變換來實現它? – elephant

相關問題