使用tabbarcontroller,shouldAutorotateToInterfaceOrientation:方法不調用肖像模式,而其他三個方向調用完美。對此有任何想法嗎?tabbarcontroller的肖像模式方向問題?
謝謝
使用tabbarcontroller,shouldAutorotateToInterfaceOrientation:方法不調用肖像模式,而其他三個方向調用完美。對此有任何想法嗎?tabbarcontroller的肖像模式方向問題?
謝謝
即使我面臨這個問題,如果你只是想知道設備的方向是否改變或者不使用通知而不是shouldAutorotateToInterfaceOrientation。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];
-(void)orientationChanged:(NSNotification *)dict
{
UIInterfaceOrientation interfaceOrientation = (UIInterfaceOrientation)[UIDevice currentDevice].orientation;
//Your code
}
對於原來的問題,在默認情況下shouldAutorotateToInterfaceOrientation爲UIDeviceOrientationPortrait回報是,如果你在shouldAutorotateToInterfaceOrientation方法返回NO,設備將認爲其在UIDeviceOrientationPortrait模式僅因此該方法shouldAutorotateToInterfaceOrientation不要求UIDeviceOrientationPortrait。
(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
//your code
return NO;
}
你是否總是在shouldAutorotateToInterfaceOrientation方法中返回NO。 – 2010-07-06 14:35:23
你試過用Device和Simulator嗎? 您是否在app_name-Info.plist中檢查了支持的方向?
我嘗試在兩個。同樣的結果。並在.plist我不改變任何東西或限制任何事情? – 2010-07-06 09:25:09
我很奇怪,你確定在PList文件中沒有「支持的界面方向」鍵嗎? – Greensource 2010-07-06 09:40:19
damm sure ..與方向有關的nuthing。 – 2010-07-06 09:47:58
沒有足夠的信息。你應該在發生這種情況的地方發佈代碼。 – 2010-07-06 09:03:46