tabbarcontroller的纵向模式方向问题?

时间:2010-07-06 09:00:22

标签: iphone uitabbarcontroller

使用tabbarcontroller,shouldAutorotateToInterfaceOrientation:方法不调用纵向模式,而其他三个方向调用完美。有没有任何想法?

谢谢

2 个答案:

答案 0 :(得分:0)

您是否尝试使用设备和模拟器? 您是否在app_name-Info.plist中检查了支持的方向?

答案 1 :(得分:0)

即使我遇到了问题,如果您只是想知道设备的方向是否改变,请使用通知而不是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 返回YES,如果在 shouldAutorotateToInterfaceOrientation 方法中返回NO,则设备会认为它在 UIDeviceOrientationPortrait 模式因此不会为 UIDeviceOrientationPortrait 调用 shouldAutorotateToInterfaceOrientation 方法。

    (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
       //your code
        return NO;
 }
相关问题