gpt4 book ai didi

swift - 为什么 UIScreen.bounds 在 iOS11 中不正确

转载 作者:行者123 更新时间:2023-12-03 09:27:58 25 4
gpt4 key购买 nike

请不要标记为重复。可用线程尚未提供答案。行为仅适用于 iOS11。

将项目从 Xcode 8 更新到 Xcode 9,现在使用 iOS11 但仍然使用 Swift 3,我有以下经验:

    print("UIScreen.main.bounds.width = \(UIScreen.main.bounds.width)")
print("self.view.frame.width = \(self.view.frame.width)")

let rect = CGRect(

x: 0,
y: 0,
width: UIScreen.main.bounds.width,
height: UIScreen.main.bounds.height * 0.25

)

打印:
UIScreen.main.bounds.width = 414.0
self.view.frame.width = 600.0

View 应该是从屏幕边缘到屏幕边缘。因此我使用了 UIScreen.main.bounds.width .但是该值对于 self.view.frame.width 的实际 View Controller 大小来说太小了.

这是为什么?我错过了什么?非常感谢帮助。

物理设备。使用 UIScreen.main.bounds.width 的相同行为

最佳答案

我有一个类似的问题,不正确的获取 UIScreen.main.bounds尺寸。尺寸小于物理屏幕。解决方案是将下一行添加到 info.plst :
key :

Launch screen interface file base name
类型:
String
值(value):
LaunchScreen
所以请检查您的 info.plist 看看它是否包含这一行。如果不是,只需添加它。希望这可以帮助。
screen shot of info.plst

关于swift - 为什么 UIScreen.bounds 在 iOS11 中不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46495605/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com