shouldAutorotateToInterfaceOrientation连续多次调用,没有任何旋转 [英] shouldAutorotateToInterfaceOrientation called several times in a row without any rotation

查看:239
本文介绍了shouldAutorotateToInterfaceOrientation连续多次调用,没有任何旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据设备轮换在我的应用中实现一些界面更改。

I am trying to implement some interface changes in my app, based on the device rotation.

我的应用是基于视图的应用。因此,它的主视图控制器有一个didload方法。

My app is a view based app. So, its main view controller has a didload method.

该应用程序以纵向方式启动。几乎所有关于设备方向的更改都会触发shouldAutorotateToInterfaceOrientation方法,但是当从任何横向方向进入设备时,不会调用此方法。

The app starts in portrait. Almost all changes on the device orientation triggers the shouldAutorotateToInterfaceOrientation method but this method is not called when the device is put on portrait, after coming from any landscape orientation.

调试时app,我已经放了一个

While debugging the app, I have put a

NSLog(@"orientation=%d", interfaceOrientation);

,我看到的很奇怪:


  • 当我运行应用程序时,在应用程序界面出现之前,应该调用6次onAutorotateToInterfaceOrientation。每次运行时,它都会为方向报告不同的数字:它在控制台上报告的顺序是:纵向,纵向,纵向,横向右侧,横向左侧,上下颠倒)(????)。

在此期间,应用程序才刚刚开始。调试器报告来自应用程序代表的所有6个调用。

During this time the app is just beginning. The debugger reports all 6 calls coming from the app's delegate.

因此,问题出现了:


  1. 当设备进入人像时,为什么没有调用AutorotateToInterfaceOrientation?

  2. 为什么代表在应用程序甚至可见之前调用此方法6次,特别是在没有轮换时正在完成?

谢谢。

推荐答案

UIViewController类参考

似乎说这个方法返回一个值指示视图控制器是否支持指定的方向。

The UIViewController Class Reference seems to say that this method returns a value "indicating whether the view controller supports the specified orientation".

它没有承诺设备现在正在旋转,它只是查询控制器可以支持哪些方向。因此声明:

It doesn't make any promises that the device is/isn't rotating right now, it's just querying to see what orientations your controller can support. Hence the statement:


您的视图控制器能够支持给定的方向,或者不支持。

Your view controller is either capable of supporting a given orientation or it is not.

这篇关于shouldAutorotateToInterfaceOrientation连续多次调用,没有任何旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆