objective-c - 具有不同方向的 UINavigationcontroller

标签 objective-c ios uinavigationcontroller

我想创建一个 UINavigationController,带有一个主视图 Controller 和一个详细 View Controller 。

主视图 Controller 可以在Portrait和LandscapeRight中旋转,而Detail View Controller只能在LandscapeRight中查看(Detail显示电影)。

设置此功能的最佳方法是什么?

最佳答案

我建议添加以下代码行

在您的主视图 Controller 上:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

     return interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationLandscapeRight;
}

以及您的详细 View Controller

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

     return interfaceOrientation == UIInterfaceOrientationLandscapeRight;
}

这应该可以解决问题。

关于objective-c - 具有不同方向的 UINavigationcontroller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9281409/

相关文章:

ios - 从 ModalViewController 返回后键盘没有出现

ios - 在flutter iOS中加载基于ip的视频流

iphone - 如何在 didReceiveRemoteNotification 中推送新的 View Controller ,以便之前的 View Controller 暂时不显示?

iphone - iOS:检测主运行循环之外的低内存崩溃

iphone - 为什么在 dismissViewControllerAnimated 之后父框架没有保持相同的大小?

ios - 同时播放 AVAudio Player 和 AVCam

swift - iOS Swift : Dismiss View Controller That Was Presented Using "Show Detail"

html - 当我关闭浏览器窗口而不是简单地消失时,导航栏中的图像会落在彼此下方。为什么?

python - 如何使用 PyObjC 在 WebKit WebView 中加载用户 CSS?

ios - 如何在字典的末尾添加一个值