Reputation: 417
I've an existing iOS App for target Device iPad Air and I want it to run on iPad PRO. It all works fine, but I need an Image to keep same Size (realSize on mm) on both devices.
The resolution of both devices is equal so I don't understand why the Image are bigger on iPad Pro. 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. Is there a way to disable this behavior.
Upvotes: 0
Views: 219
Reputation: 52602
If you are building against iOS 8 SDK, then you need to add a launch image at the right size. Otherwise Apple assumes that you don't know how to handle in iPad Pro and scales everything up. Check where your code gets the screen size and NSLog it; if you get 1024 x 768 then you are missing the right launch image.
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.
Upvotes: 2
Reputation: 850
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.
- (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);
}
}
Upvotes: 1