0

我想从服务器下载一张图片并将其设置为 iphone4s 的全屏,我使用 UIScreen *mainScreen = [UIScreen mainScreen];并使用此主屏幕来获取尺寸(它是 960x640)。当应用程序启动时,我将代码插入 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 的大小,发现窗口的大小是 320x480。这怎么发生的?

这是我如何获得尺寸:

UIScreen *mainScreen = [UIScreen mainScreen];
UIScreenMode *ScreenMode = [mainScreen currentMode];
CGSize size = [ScreenMode size];
CGFloat screenWidth = size.width;
CGFloat screenHeight = size.height;
4

1 回答 1

1

这就是点和像素的区别。

UIScreen 以像素为单位返回大小,但 UIKit 处理的是点。这是有关该主题的一些 Apple 文档: https ://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/WindowsandViews/WindowsandViews.html#//apple_ref/doc/uid/TP40009503-CH2-SW15

于 2013-08-23T06:48:21.767 回答