在iOS上,为什么shouldAutorotateToInterfaceOrientation被称为10,12或13次? [英] On iOS, why is shouldAutorotateToInterfaceOrientation called 10, 12, or 13 times?

查看:120
本文介绍了在iOS上,为什么shouldAutorotateToInterfaceOrientation被称为10,12或13次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果为iPad创建了Single View应用程序,则根据为plist设置的Supported Device Orientation,以及 shouldAutorotateToInterfaceOrientation 返回的内容, shouldAutorotateToInterfaceOrientation 可以被调用10次,12次甚至13次。

If a Single View app is created for iPad, depending on the Supported Device Orientation is set for the plist, and what shouldAutorotateToInterfaceOrientation returns, shouldAutorotateToInterfaceOrientation can be called 10, 12, or even 13 times.

一个简单的例子是,如果支持设备方向设置为横向左边和 shouldAutorotateToInterfaceOrientation 也只为Landscape Left返回 YES ,然后如果我以Landscape Left方向启动应用程序,那么 shouldAutorotateToInterfaceOrientation 将连续12次调用。如果我以其他方向持有并启动应用程序,那么它是13次。

One simple case is, if the "Support Device Orientation" is set to Landscape Left, and shouldAutorotateToInterfaceOrientation also returns YES only for Landscape Left, then if I start the app in Landscape Left orientation, then shouldAutorotateToInterfaceOrientation will be called 12 times in a row. If I hold it in other orientation and start the app, then it is 13 times.

连续多次调用它的原因是什么?

What is the reason that it is called so many times in a row?

推荐答案

正如我在UIDevice.h中看到的那样,方向类型不用作掩码,应该执行多个请求:

As i can see at UIDevice.h, orientation type is not used as a mask and several requests should be performed:


  • 检查当前方向是否受支持

  • 如果没有,请找到支持的方向1-3或1 -4个请求

对于单个方向更改,整个过程可能会发生多次(例如,系统可能希望发送正确的方向)通知应用程序窗口状态栏可能想要独立检查方向,欢迎来到OOP,我不是说它发生了,但它可能)虽然第一或第二阶段的结果可能以某种方式缓存一个组件而不是另一个。

The whole process could happen more than one time for a single orientation change (e.g. the system might want to send the correct notification to the application window the status bar might want to check the orientation independently, welcome to OOP, i'm not saying it happens, but it might) while the results of the 1st or 2nd stages might be somehow cached by one component and not by another.

这篇关于在iOS上,为什么shouldAutorotateToInterfaceOrientation被称为10,12或13次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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