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 のドキュメントは次のとおりです

于 2013-08-23T06:48:21.767 に答える