像往常一樣我有一個UIViewController的子類。當我加載應用程序時,我需要調整一些必須以編程方式放置的元素。當然,大小取決於接口方向:所以,我所做的:UIViewController interfaceOrientation問題
- (void)viewDidLoad {
switch([self interfaceOrientation]) {
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationPortraitUpsideDown:
NSLog(@"Portrait");
break:
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:
NSLog(@"Landscape");
break;
}
但是,沒有模擬器/設備的方向的事情,情況總是肖像在viewDidLoad中/ WillAppear,即使一切正常旋轉。 在Plist中,我添加了所有支持的方向。 提示?
碰到完全相同的問題!這在模擬器中一直是個問題。 最好的是:打破「willRotate」,它告訴你它會旋轉到風景。接下來它在layoutSubview中打破。如果你檢查那裏的方向,它是肖像! WTF? – Krumelur 2011-11-03 20:44:13
難道你應該重寫'shouldAutorotateToInterfaceOrientation'並返回YES嗎?如果你這樣做,把你的代碼移到那個方法。 – Mazyod 2012-05-19 04:55:44