如何在iOS上支持横向模式?是否应该只调用一次AutoRotateTointerFaceOrientation
我正在尝试在我的gl iOS应用程序中支持横向模式。我有一个窗口、一个gl视图和一个视图控制器,其中有一个方法shouldAutorotateToInterfaceOrientation,返回YES。我是这样设置的:如何在iOS上支持横向模式?是否应该只调用一次AutoRotateTointerFaceOrientation,ios,Ios,我正在尝试在我的gl iOS应用程序中支持横向模式。我有一个窗口、一个gl视图和一个视图控制器,其中有一个方法shouldAutorotateToInterfaceOrientation,返回YES。我是这样设置的: window = [[UIWindow alloc] initWithFrame:rect]; GLView *glView = [[GLView alloc] initWithFrame:rect]; glView.delegate = self; view_cont
window = [[UIWindow alloc] initWithFrame:rect];
GLView *glView = [[GLView alloc] initWithFrame:rect];
glView.delegate = self;
view_controller = [ViewController alloc];
view_controller.view = glView;
window.rootViewController = view_controller;
这发生在方法ApplicationIDFinishLaunching上。问题在于,对于纵向模式,该方法应该只调用一次AutoRotateTointerFaceOrientation。我仍然在视图中获取事件,但是自动旋转的方法再也不会被调用
我设置的对吗?没有nib文件,只有代码
谢谢。您应该在ViewController实例上调用init它是UIViewController子类吗 您应该重写以下UIViewController方法
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
调用should autorotate并不意味着将进行旋转,这在UIViewController类参考中进行了解释
默认情况下,UIViewController类以纵向模式显示视图
只有若要支持其他方向,必须覆盖
shouldAutorotateToInterfaceOrientation:方法,并为任何
子类支持的方向。如果
您的视图配置正确,这可能就是您所要做的全部。
但是,UIViewController类为您提供了额外的挂钩
根据需要实施其他行为
暂时关闭不需要或可能需要的功能
否则在方向更改过程中会导致问题,您可以
重写willRotateToInterfaceOrientation:duration:方法和
在那里执行所需的操作。然后可以覆盖
didRotateFromInterfaceOrientation:方法并使用它重新启用这些
方向更改完成后的特征
若要为方向更改添加动画,请替代
WillAnimateRotationInterfaceOrientation:持续时间:方法和执行
你的动画在那里
是的,问题是我没有给init打电话。如果AutoRotateTointerFaceOrientation足够,则如果希望在旋转动画期间收到通知,则其他选项也足够