Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Dec 2, 2012, 01:26 PM   #1
IDMah
macrumors regular
 
Join Date: May 2011
1 to 1.15 Scaling from iphone to ipad and phone5

Hi all.

I can determine the screen Size by:
Code:
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
        if ([UIScreen mainScreen].scale == 2.0f) {
            CGSize result = [[UIScreen mainScreen] bounds].size;
            CGFloat scale = [UIScreen mainScreen].scale;
            result = CGSizeMake(result.width * scale, result.height * scale);
            
            scalerX=1;
            scalerY=1;
            
            NSLog(@"Screen is X:%f Y:%f",scalerX,scalerY);
            
            if(result.height == 960){
                NSLog(@"iPhone 4, 4s Retina Resolution");
                             
            }
            if(result.height == 1136){
                NSLog(@"iPhone 5 Resolution");
                             }
        } else {
            NSLog(@"iPhone Standard Resolution");
            CGSize result = [[UIScreen mainScreen] bounds].size;
            CGFloat scale = [UIScreen mainScreen].scale;
            result = CGSizeMake(result.width * scale, result.height * scale);
            
            scalerX=1;
            scalerY=1;
            
            NSLog(@"Screen is X:%f Y:%f",scalerX,scalerY);
            
        }
    } else {
        CGSize result = [[UIScreen mainScreen] bounds].size;
        CGFloat scale = [UIScreen mainScreen].scale;
        result = CGSizeMake(result.width * scale, result.height * scale);
        
        if ([UIScreen mainScreen].scale == 2.0f) {
            NSLog(@"iPad Retina Resolution");
         } else{
            NSLog(@"iPad Standard Resolution");
                       
        }
        scalerX=2.0; <--- why does this work better ??
        scalerY=2.0;
 
       // tried ratio of 326/163 which is 2 anyway.
 
        NSLog(@"Screen is X:%f Y:%f",scalerX,scalerY);
        
       
    }
but maybe because I eyeballed the placement of the Bitmaps
if I multiply the currentX * scalerX it's off also

tried
Code:
positionX =currentX * scalerX 
// also tried this .. both are off for ipad //
positionX = currentX*(result.width/320);
What am I doing wrong? Is the original iphone resolution not 320 X 480??
what should I scale by??

thanks
Ian
IDMah is offline   0 Reply With Quote
Old Dec 2, 2012, 02:35 PM   #2
ArtOfWarfare
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
I'm confused. What are you trying to do and what are you getting?
__________________
Battery Status - On the Mac App Store
The only app that'll estimate when your wireless devices will need their batteries changed.
Including the ones paired with other Macs on your network.
ArtOfWarfare is offline   0 Reply With Quote
Old Dec 2, 2012, 07:46 PM   #3
Duncan C
macrumors 6502a
 
Duncan C's Avatar
 
Join Date: Jan 2008
Location: Northern Virginia
 
Quote:
Originally Posted by IDMah View Post
Hi all.

I can determine the screen Size by:
Code:
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
        if ([UIScreen mainScreen].scale == 2.0f) {
            CGSize result = [[UIScreen mainScreen] bounds].size;
            CGFloat scale = [UIScreen mainScreen].scale;
            result = CGSizeMake(result.width * scale, result.height * scale);
            
            scalerX=1;
            scalerY=1;
            
            NSLog(@"Screen is X:%f Y:%f",scalerX,scalerY);
            
            if(result.height == 960){
                NSLog(@"iPhone 4, 4s Retina Resolution");
                             
            }
            if(result.height == 1136){
                NSLog(@"iPhone 5 Resolution");
                             }
        } else {
            NSLog(@"iPhone Standard Resolution");
            CGSize result = [[UIScreen mainScreen] bounds].size;
            CGFloat scale = [UIScreen mainScreen].scale;
            result = CGSizeMake(result.width * scale, result.height * scale);
            
            scalerX=1;
            scalerY=1;
            
            NSLog(@"Screen is X:%f Y:%f",scalerX,scalerY);
            
        }
    } else {
        CGSize result = [[UIScreen mainScreen] bounds].size;
        CGFloat scale = [UIScreen mainScreen].scale;
        result = CGSizeMake(result.width * scale, result.height * scale);
        
        if ([UIScreen mainScreen].scale == 2.0f) {
            NSLog(@"iPad Retina Resolution");
         } else{
            NSLog(@"iPad Standard Resolution");
                       
        }
        scalerX=2.0; <--- why does this work better ??
        scalerY=2.0;
 
       // tried ratio of 326/163 which is 2 anyway.
 
        NSLog(@"Screen is X:%f Y:%f",scalerX,scalerY);
        
       
    }
but maybe because I eyeballed the placement of the Bitmaps
if I multiply the currentX * scalerX it's off also

tried
Code:
positionX =currentX * scalerX 
// also tried this .. both are off for ipad //
positionX = currentX*(result.width/320);
What am I doing wrong? Is the original iphone resolution not 320 X 480??
what should I scale by??

thanks
Ian
iPhone, iPad, and iPhone 5 all have different aspect ratios. There is no scale factor that will map layouts to all those devices without distorting it.

iPhone = 320:480 = .6666
iPad = 768:1024 = .7500
iPhone 5 = 320:580 = .5517

The iPad screen is also so much bigger than the iPhone screen that the same layout doesn't usually work. You generally need to rethink your forms design for the iPad, and put more functionality on one screen.

For example, in our company's location placemarking app, Save My Place, the iPhone version has a screen for the map view, a separate screen for the list of saved locations, and a third screen for the compass view. On the iPad version, all of that content fits quite nicely on a single screen.
__________________
Regards,
Duncan Champney, WareTo.
Check out our latest iOS app, Face Dancer, available for free on the App Store.
Duncan C is offline   0 Reply With Quote
Old Dec 3, 2012, 12:51 PM   #4
IDMah
Thread Starter
macrumors regular
 
Join Date: May 2011
Never an easy way out eh? hahaha !!!

Thanks all !!!

Was looking for an easy way out.. but because it was / is my first app.
I hard coded the positions. Guess I'm going to have to do it the painful way.

Reposition all the graphics by hand..

thanks again.. esp for the Ratios. should help scaling it at least.

thanks
Ian
IDMah is offline   0 Reply With Quote
Old Dec 3, 2012, 01:30 PM   #5
Duncan C
macrumors 6502a
 
Duncan C's Avatar
 
Join Date: Jan 2008
Location: Northern Virginia
 
Quote:
Originally Posted by IDMah View Post
Thanks all !!!

Was looking for an easy way out.. but because it was / is my first app.
I hard coded the positions. Guess I'm going to have to do it the painful way.

Reposition all the graphics by hand..

thanks again.. esp for the Ratios. should help scaling it at least.

thanks
Ian

No, you should not reposition everything by hand.

You should not hard-code the positions of your views. You should use an XIB or storyboard. If you did that then you could use the "struts and springs" controls in interface builder to make your views adjust automatically to different view sizes and orientations. The idea is that you determine which edges stick to the sides of the containing view (struts), and which sides are allowed to float, and you tell each view if it should stay the same size or resize (springs). You can get pretty flexible resizing behavior that way, and it is a skill you should invest time in learning.

Note that iOS 6 includes a more sophisticated resizing system known as autoLayout, but that only works under iOS 6,
__________________
Regards,
Duncan Champney, WareTo.
Check out our latest iOS app, Face Dancer, available for free on the App Store.
Duncan C is offline   0 Reply With Quote
Old Dec 3, 2012, 02:09 PM   #6
goMac
macrumors 603
 
Join Date: Apr 2004
Quote:
Originally Posted by IDMah View Post
Thanks all !!!

Was looking for an easy way out.. but because it was / is my first app.
I hard coded the positions. Guess I'm going to have to do it the painful way.
Don't do this. Write something that can position the graphics for any possible screen size.

You don't want to be screwed if Apple comes out with a new device at a different aspect ratio or resolution.
goMac is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
4s IOS 7 TV Out Not Scaling koa iOS 7 0 Oct 10, 2013 12:22 PM
iPad Mini: Developers - Is there any truth to the scaling claims (iPad Mini, battery life, etc)? macbook123 iPad 30 Nov 5, 2012 03:00 PM
using phone5 naked scratch camera lens? Jayohwhy iPhone 1 Oct 11, 2012 10:34 AM
iPad app scaling: why doesn't the iPad use iPhone 5 size macuserx86 iOS 6 6 Sep 26, 2012 07:36 AM
Who's scaling their rMBP dailybibliotaph MacBook Pro 18 Jun 26, 2012 11:25 AM

Forum Jump

All times are GMT -5. The time now is 08:22 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC