简体   繁体   English

如何在启动时以编程方式强制iPad进入1x或2x模式?

[英]How do I force iPad to 1x or 2x mode programmatically at startup?

I can detect my iPad device running an iPhone app in 1x or 2x scale, thanks to an earlier post here: detect iPad 2x button for iPhone app 我可以检测我的iPad设备以1x或2x规模运行iPhone应用程序,这要归功于此前的帖子: 检测iPad应用程序的iPad 2x按钮

What I would like to do is to serialise this setting into NSUserDefaults when it is changed by the user so that force the app into 1x or 2x at startup. 我想要做的是在用户更改NSUserDefaults时将其设置为NSUserDefaults ,以便在启动时将应用程序强制为1x或2x。 Currently the app always starts in 1x mode. 目前,应用程序始终以1x模式启动。 Please note again I can detect when the user switches scale between 1x and 2x, my problem is to set the scale programmatically at startup. 请再次注意我可以检测到用户在1x和2x之间切换比例,我的问题是在启动时以编程方式设置比例。

It seems [[UIScreen mainScreen] screen] is read-only. 似乎[[UIScreen mainScreen] screen]是只读的。 However I know that some apps such as Google+ is capable of doing this. 但我知道有些应用程序(如Google+)可以执行此操作。 But how? 但是怎么样?

For me, iOS seems to remember the "2x" setting for my apps. 对我来说,iOS似乎记得我的应用程序的“2x”设置。 Perhaps it gets reset when debugging through Xcode. 也许在通过Xcode进行调试时会重置。 I would test with a release build and run it normally outside the debugger. 我将使用发布版本进行测试,并在调试器外部正常运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM