簡體   English   中英

無法在iphone5上顯示640x1136圖像

[英]can't display 640x1136 image on iphone5

我已將Default-568h@2x.png啟動圖像添加到我的應用中。 該應用需要在“真實”啟動圖像之后顯示第二個啟動圖像。 因為UIImage imageNamed:方法不會像自動加載視網膜圖像那樣自動加載較高的圖像,所以我添加了一些代碼來檢測屏幕尺寸並顯示正確的圖像:

-(void)pickRightImage
{
    CGSize result = [[UIScreen mainScreen] bounds].size;
    UIImageView *imgv = [self loadingImage];

    UIImage *img;

    if(result.height == 480)
    {
        img = [UIImage imageNamed:@"loading_screen.png"];
    } else if([UIScreen mainScreen].scale == 2.f && result.height == 568) {
        // iPhone 5
       img = [UIImage imageNamed:@"loading_screen-568h@2x.png"];       
    }
    [imgv setImage:img];
}

imageView占據了NIB中名為MainWindow的整個屏幕,並且我選中了名為“啟動時全屏”的復選框。但是,圖像從未占據整個屏幕。 (盡管啟動圖像可以。)第二個圖像用字母框起來,就好像它是一個較小的圖像一樣,而且我從未包括過高的啟動圖像。

無論如何,是否可以在4英寸iphone5上以編程方式顯示全屏圖像? 為什么我的圖像總是調整大小?

[UIImage imageNamed:]將為您添加@2x 所以你應該指定

img = [UIImage imageNamed:@"loading_screen-568h.png"];

同時測試4英寸屏幕和Retina標准(比例= 2)也沒有用。所有具有4英寸屏幕(高568px)的設備都是Retina顯示器,因此可以假設如果height == 568,則用戶具有iPhone 5:更換

if ([UIScreen mainScreen].scale == 2.f && result.height == 568)

if ([UIScreen mainScreen].bounds.size.height == 568)

而且你很好。

我在主視圖控制器上進行了測試。 另外,在“目標”>“摘要”>“狀態欄”>“可見性”上,選中“在應用程序啟動期間隱藏”。

- (void)viewDidLoad
{
    [super viewDidLoad];
    UIImageView *iv = [[UIImageView alloc] initWithFrame:self.view.bounds];
    iv.image = [UIImage imageNamed:@"Second-default568h@2x.png"];
    [self.view addSubview:iv];
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM