- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我只是创建了一个新的单 View 应用程序,并在 ViewController.m 文件中编写了三个函数。
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscape;
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
最佳答案
您必须使用 UINavigationController 子类(不确定您在项目中使用导航...)并在子类中实现这些方法。不要忘记将您的子类设置为 View Controller 导航 Controller
导航 Controller 子类的示例:
// add this in your CustomNavigationController.h file
#import <UIKit/UIKit.h>
@interface CustomNavigationController : UINavigationController <UINavigationControllerDelegate>
@end
// add this in your : CustomNavigationController.m file
#import "CustomNavigationController.h"
@interface CustomNavigationController ()
@end
@implementation CustomNavigationController
- (BOOL)shouldAutorotate {
return [self.visibleViewController shouldAutorotate];
}
- (NSUInteger)supportedInterfaceOrientations {
return [self.visibleViewController supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return [self.visibleViewController preferredInterfaceOrientationForPresentation];
}
@end
关于ios preferredInterfaceOrientationForPresentation 未调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33951846/
我只是创建了一个新的单 View 应用程序,并在 ViewController.m 文件中编写了三个函数。 -(BOOL)shouldAutorotate { return YES; } -(
我有一个场景,其中我有一个带有 5 个选项卡的 UITabbarController。每个选项卡都包含一个 UINavigationController。 现在在 UINavigationContro
我试图以编程方式强制一个弹出 View 为横向,同时我在项目设置中将应用程序的设备方向设置为纵向。我的代码如下所示: override func shouldAutorotate() -> Bool
我正在使用 iOS 8 的 UIPresentationController 编写自定义模式演示文稿。呈现的 Controller 具有首选界面方向 UIInterfaceOrientationLan
此错误没有意义,因为首选方向 UIInterfaceOrientationLandscapeRight 由支持的方向返回 //iOS6 -(BOOL)shouldAutorotate { re
我的应用程序窗口的 Root View Controller 是 UINavigationController 的子类。我已将此代码添加到类(class)中: - (BOOL)shouldAutoro
我们正在经历this crash来自 GoogleSignIn iOS 框架 v4.0.1(通过 CocoaPods 链接)。 致命异常:UIApplicationInvalidInterfaceOr
我正在使用 MSNavigationPaneViewController from here并进行轮换工作。我已经覆盖了根 UINavigationController 中的旋转方法 -(BOOL)s
我在尝试阻止某些 View 中的方向时遇到问题,但代码不起作用。 我在每个 View 中都使用这条线: - (BOOL)shouldAutorotate { return YES; } - (
我是一名优秀的程序员,十分优秀!