2016-06-20 72 views
0

我已經爲目標設備iPad Air購買了現有的iOS應用程序,我希望它可以在iPad PRO上運行。這一切工作正常,但我需要一個圖像在兩個設備上保持相同的尺寸(真實尺寸在毫米)。IPad Air App在IPad Pro上擴大規模

這兩款設備的分辨率相同,所以我不明白爲什麼圖像在iPad Pro上更大。這是我繪製圖像的方式。

- (void) drawNewNumberImage { 
    int index = arc4random()%_allNumbers.count; 
    while([_currentNumber isEqualToString:[_allNumbers objectAtIndex:index]]) { 
     index = arc4random()%_allNumbers.count; 
    } 
    _currentNumber = [_allNumbers objectAtIndex:index]; 
    int s = _size; 
    //_imgView.image = [UIImage imageNamed:[_allNumbers objectAtIndex:index]]; 
    _imgView.image = [ImageProvider getPDFVectorImage:[_allNumbers objectAtIndex:index] AndFontSize:s]; 
    CGRect frame = _imgView.frame; 

    frame.size = CGSizeMake(s, s); 
    _imgView.frame = frame; 

    _imgView.center = CGPointMake(CGRectGetWidth(self.view.frame)/2 , CGRectGetHeight(self.contentView.frame)/2); 
} 

iPad Pro似乎只是擴大了所有的應用程序。有沒有辦法來禁用這種行爲。

回答

1

如果您正在構建針對iOS 8的SDK,那麼你需要以適當的尺寸添加啓動圖像。否則,蘋果公司假設你不知道如何在iPad Pro中處理和擴展一切。檢查你的代碼在哪裏獲得屏幕大小和NSLog它;如果你得到1024 x 768,那麼你錯過了正確的啓動圖像。

順便說一句。你應該真的,真的而不是看看屏幕的高度或寬度,並做出假設,就像另一個答案一樣,因爲在iPad Pro上使用分屏時,您的假設可能會非常非常錯誤,並且會讓您陷入麻煩。

+0

確實是這樣的情況。我在AppDelagate方法中創建了一個斷點,self.window的大小爲1024 x 768.爲iPad Air和iPad Pro設置特定啓動圖像的最佳方法是什麼? – feldeOne

+0

解決了這個問題http://stackoverflow.com/questions/25926661/how-do-i-create-launch-images-for-iphone-6-6-plus-landscape-only-apps – feldeOne

1

你可以嘗試檢測,如果它是一臺iPad Pro和創建要否則你的工作的默認大小將揭開新的大小。

- (void) drawNewNumberImage { 


if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){ 
CGSize result = [[UIScreen mainScreen] bounds].size; 
if(result.height == 1366) 
{ 
    // iPad Pro 
    //add your iPad Pro sizes 

} else { 

int index = arc4random()%_allNumbers.count; 
while([_currentNumber isEqualToString:[_allNumbers objectAtIndex:index]]) { 
    index = arc4random()%_allNumbers.count; 
} 
_currentNumber = [_allNumbers objectAtIndex:index]; 
int s = _size; 
//_imgView.image = [UIImage imageNamed:[_allNumbers objectAtIndex:index]]; 
_imgView.image = [ImageProvider getPDFVectorImage:[_allNumbers objectAtIndex:index] AndFontSize:s]; 
CGRect frame = _imgView.frame; 

frame.size = CGSizeMake(s, s); 
_imgView.frame = frame; 
_imgView.center = CGPointMake(CGRectGetWidth(self.view.frame)/2 , CGRectGetHeight(self.contentView.frame)/2); 
} 

}