ios 在storyboard中shouldautorate函数不起作用

在ios中,我用storyboard写一个应用。需要有横屏和竖屏。并且都不能旋转。我在工程中,选择了两个模式,即横屏和竖屏,然后在一个viewcontroller中,添加了一下这些函数,期望这个只支持横屏:
- (BOOL)shouldAutorotate
{
return NO;
}

- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}

但是当我旋转屏幕的时候,屏幕还是跟着旋转了。
我以前一个app用xib的方式,就没碰到这个问题。请教。

阅读 3.1k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题