界面方向仅限横向

时间:2011-06-26 15:24:13

标签: objective-c ios cocoa-touch uiviewcontroller uiinterfaceorientation

在我的视图控制器中,我已实现此功能:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}

但我的viewcontroller没有切换方向。我错过了什么?感谢

1 个答案:

答案 0 :(得分:0)

我这样做:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    if (interfaceOrientation == UIDeviceOrientationLandscapeLeft ||  interfaceOrientation ==  UIDeviceOrientationLandscapeRight) 
    {
        return YES;
    }
    return NO;
}

这基本上就是你在做什么。确保InterfaceBuilder也可以在横向模式下查看您的视图。