为什么我的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