从NIB加载的自定义视图始终旋转90度

时间:2014-04-09 01:20:19

标签: ios cocoa-touch uiview uiviewcontroller

我有UIViewController仅适用于横向,即配置了

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationLandscapeLeft;
}

我有一个自定义UIView视图控制器),它有自己的NIB。我用

将它加载到视图控制器中
- (void)viewDidLoad
{
    [super viewDidLoad];

    ISMainView *customView = [[[NSBundle mainBundle] loadNibNamed:@"ISMainView" owner:nil options:nil] lastObject];
    [self.view addSubview:customView];
}

当视图加载时,它显示旋转90度,就好像它想要纵向一样。

知道什么是错的吗? UIView对自己的方向一无所知,对吧?所以问题必须是View Controller?

1 个答案:

答案 0 :(得分:0)

所以看来问题是由

引起的
-(BOOL)shouldAutorotate {
    return NO;
}

我不确定原因,但关闭shouldAutorotate会阻止子视图设置为正确的设备方向,即使设备从不旋转。奇。

相关问题