簡體   English   中英

iPad Air App在iPad Pro上擴大規模

[英]IPad Air App scaled up on IPad Pro

我已經有一個用於目標設備iPad Air的現有iOS應用,並且希望它可以在iPad PRO上運行。 一切正常,但是我需要一個Image來在兩個設備上保持相同的大小(mm上為realSize)。

兩種設備的分辨率都相等,所以我不明白為什么iPad Pro上的Image更大。 這就是我繪制圖像的方式。

- (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似乎只是在擴展所有App。 有沒有一種方法可以禁用此行為。

您可以嘗試檢測它是否為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); 
}

}

如果要針對iOS 8 SDK進行構建,則需要以正確的大小添加啟動映像。 否則,Apple會假設您不知道如何在iPad Pro中進行處理,並且會放大所有內容。 檢查您的代碼在何處獲得屏幕尺寸並使用NSLog進行顯示; 如果得到1024 x 768,則缺少正確的啟動圖像。

順便說一句。 您應該真的, 不要真的像其他答案一樣看屏幕的高度或寬度並做出假設,因為在iPad Pro上使用分屏時,您的假設可能非常非常錯誤,並給您帶來麻煩。

暫無
暫無

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

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