简体   繁体   English

iPad Air App在iPad Pro上扩大规模

[英]IPad Air App scaled up on IPad Pro

I've an existing iOS App for target Device iPad Air and I want it to run on iPad PRO. 我已经有一个用于目标设备iPad Air的现有iOS应用,并且希望它可以在iPad PRO上运行。 It all works fine, but I need an Image to keep same Size (realSize on mm) on both devices. 一切正常,但是我需要一个Image来在两个设备上保持相同的大小(mm上为realSize)。

The resolution of both devices is equal so I don't understand why the Image are bigger on iPad Pro. 两种设备的分辨率都相等,所以我不明白为什么iPad Pro上的Image更大。 This is the way I draw the Images. 这就是我绘制图像的方式。

- (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);
}

It seems like the iPad Pro just scales up all the App. iPad Pro似乎只是在扩展所有App。 Is there a way to disable this behavior. 有没有一种方法可以禁用此行为。

You can try to detect if it is an iPad Pro and create the new sizes you want else your working default sizes will kick in. 您可以尝试检测它是否为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); 
}

}

If you are building against iOS 8 SDK, then you need to add a launch image at the right size. 如果要针对iOS 8 SDK进行构建,则需要以正确的大小添加启动映像。 Otherwise Apple assumes that you don't know how to handle in iPad Pro and scales everything up. 否则,Apple会假设您不知道如何在iPad Pro中进行处理,并且会放大所有内容。 Check where your code gets the screen size and NSLog it; 检查您的代码在何处获得屏幕尺寸并使用NSLog进行显示; if you get 1024 x 768 then you are missing the right launch image. 如果得到1024 x 768,则缺少正确的启动图像。

BTW. 顺便说一句。 You should really, really not look at the height or width of the screen and make assumption, like another answer does, because with split screen on iPad Pro your assumptions may be very, very wrong and get you into trouble. 您应该真的, 不要真的像其他答案一样看屏幕的高度或宽度并做出假设,因为在iPad Pro上使用分屏时,您的假设可能非常非常错误,并给您带来麻烦。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM