为什么我的UIScreen和UIWindow大小不匹配?
我想从服务器下载图片,并将其设置为iphone4s的全屏,我使用UIScreen *mainScreen = [UIScreen mainScreen];
并使用这个主屏幕来获得大小(它是960×640)。 当应用程序启动时,我将代码插入AppDelegate。
if (im!=nil){ UIImageView *splashScreen = [[UIImageView alloc] initWithImage:im]; [self.window addSubview:splashScreen]; [UIView animateWithDuration:3 animations:^{splashScreen.alpha = 0.99;} completion:(void (^)(BOOL)) ^{ [splashScreen removeFromSuperview]; }]; }
我注意到大小是不正确的,然后我注销self.window的大小,发现窗口的大小是320×480。 这怎么发生的?
这里是我如何得到尺寸:
UIScreen *mainScreen = [UIScreen mainScreen]; UIScreenMode *ScreenMode = [mainScreen currentMode]; CGSize size = [ScreenMode size]; CGFloat screenWidth = size.width; CGFloat screenHeight = size.height;
这是点和像素之间的差异。
UIScreen以像素为单位返回大小,但是UIKit会处理点数。 以下是关于此主题的一些Apple文档: https : //developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/WindowsandViews/WindowsandViews.html#//apple_ref/doc/uid/TP40009503-CH2-SW15
- 具有多选的UICollectionView不会选择十几个项目
- 无法通过https播放iPad <audio>
- 框架阴影在Retina iPad上的iOS 7中的WebKit中传播错误
- 使用SnapKit编写自动布局约束
- 如何解决无法获取默认令牌错误?
- 使用select器'touchesBegan:withEvent:'具有不兼容types'(NSSet,UIEvent) – >()'的覆盖方法
- parsingiOS SDK:奇怪“无法做比较查询的types:(NULL)”
- 如何用date时间值sortingNSArray?
- 对成员’tableView(_:numberOfRowsInSection :)’的模糊引用为什么会出现此错误?