[英]Why does my UIScreen and UIWindow size not match?
I want to download a picture from the server and set it as fullscreen for the iphone4s, i use UIScreen *mainScreen = [UIScreen mainScreen];
我想从服务器下载图片并将其设置为iphone4s的全屏,我使用
UIScreen *mainScreen = [UIScreen mainScreen];
and use this mainscreen to get the size (it's 960x640). 并使用该主屏幕获取尺寸(为960x640)。 When the app launches, I insert the code to AppDelegate .
应用启动时,我将代码插入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];
}];
}
I noticed the size is incorrect, then I logged out the size of the self.window and found the size of the window is 320x480. 我注意到大小不正确,然后我注销了self.window的大小,发现窗口的大小为320x480。 How did this happen?
这怎么发生的?
Here is how i get the sizes: 这是我得到尺寸的方法:
UIScreen *mainScreen = [UIScreen mainScreen];
UIScreenMode *ScreenMode = [mainScreen currentMode];
CGSize size = [ScreenMode size];
CGFloat screenWidth = size.width;
CGFloat screenHeight = size.height;
That's the difference between points and pixels. 那就是点和像素之间的差异。
The UIScreen returns the size in pixels, however UIKit deals with points. UIScreen返回以像素为单位的大小,但是UIKit处理点。 Here's some Apple documentation on the subject: https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/WindowsandViews/WindowsandViews.html#//apple_ref/doc/uid/TP40009503-CH2-SW15
这是有关此主题的一些Apple文档: https : //developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/WindowsandViews/WindowsandViews.html#//apple_ref/doc/uid/TP40009503-CH2-SW15
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.