简体   繁体   English

[UIScreen mainScreen] .bounds返回错误的宽度,高度

[英][UIScreen mainScreen].bounds returns wrong width,height

Trying to port iPad app to iPhone. 尝试将iPad应用程序移植到iPhone。 When I set device type to iPhone and execute below 当我将设备类型设置为iPhone并在下面执行时

[[UIScreen mainScreen] bounds]

returns width,height (480,320) even in iPhone 6+. 即使在iPhone 6+中,也返回宽度,高度(480,320)。 but when I create new clean project for iPhone 6+ it returns (736,414).right coordinate. 但是当我为iPhone 6+创建新的干净项目时,它将返回(736,414).right坐标。 How can I fix it ? 我该如何解决?

I find way based on comments..thanks. 我发现基于评论的方式..谢谢。 iPhone app seems to decide resolution based on Launch Screen !! iPhone应用程序似乎根据启动屏幕决定分辨率! Long time ago. 很久以前。 Launch Screen was just image files for each devices. 启动屏幕只是每个设备的图像文件。 But now it was replace with 'Launch Screen.storyboard' file. 但现在它已被“启动Screen.storyboard”文件替换。 If you app don't have file..it works very oddly. 如果您的应用程序没有文件..,它的工作原理很奇怪。 So App should have Launch Screen file.. 因此,App应该具有启动屏幕文件。

New File -> iOS(Interface) -> Launch Screen 新文件-> iOS(接口)->启动屏幕

and

Link this file to your project 将此文件链接到您的项目

TARGETS -> General -> App Icons and Launch Image -> Launch Screen File 目标->常规->应用程序图标和启动图像->启动屏幕文件

Type newly created file name manually (Launch Screen.storyboard) 手动键入新创建的文件名(启动Screen.storyboard)

Done !! 做完了!

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

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