我想从服务器上下载一张图片,并将其设置为iphone4s的全屏,我使用UIScreen *mainScreen = [UIScreen mainScreen];
并使用此主屏幕来获取大小(960x640)。当应用程序启动时,我将代码插入AppDelegate。为什么我的UIScreen和UIWindow尺寸不匹配?
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;
显示如何从'UIScreen'获得大小。尺寸应该是点(而不是像素),所以两者都应该是320x480。 – rmaddy
使用'UIScreen bounds'来获取像'UIWindow'一样大小的点。 'UIScreenMode'以像素为单位。在这两个属性的文档中明确指出了这一点。 – rmaddy