1
我嘗試手動旋轉視圖時出現問題。例如,我有一個視圖控制器在橫向上運行,並且我在該視圖上有一個按鈕。我想點擊該按鈕強制將視圖旋轉爲縱向(倒置縱向)。我搜索但找不到答案。iphone:點擊按鈕將旋轉視圖
感謝您的幫助
我嘗試手動旋轉視圖時出現問題。例如,我有一個視圖控制器在橫向上運行,並且我在該視圖上有一個按鈕。我想點擊該按鈕強制將視圖旋轉爲縱向(倒置縱向)。我搜索但找不到答案。iphone:點擊按鈕將旋轉視圖
感謝您的幫助
你可以試試這個:
- (void)buttonPressed {
// check current orientation
if ([[UIApplication sharedApplication] statusBarOrientation] != UIDeviceOrientationLandscapeLeft) {
// no, the orientation is wrong, we must rotate the UI
self.view.userInteractionEnabled = NO;
// setup status bar
[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationLandscapeLeft animated:NO];
// rotate main view, in this sample the view of navigation controller is the root view in main window
[self.view setTransform: CGAffineTransformMakeRotation(M_PI/2)];
// set size of view
[self.view setFrame:CGRectMake(0, 0, 748, 1024)];
}
}
如何找出通用應用程序(iPhone 4/5,iPad/iPad視網膜/ iPad迷你)的幀大小? – peetonn 2013-08-11 01:45:51
可以發佈您遇到有問題的代碼。 – Bazinga 2012-07-09 03:18:44
對不起,這只是我的想法,我還沒有代碼。 – haisergeant 2012-07-09 03:33:39
我給你一個答案。 – Bazinga 2012-07-09 03:35:23