How can I make a (real) universal app, especially about size & rotation ?

My questions are basic.

1/ Size
I still have to figure out how I can deal with the size side of my app.

AFAIK, there are 3 targets:
iphone/ipod
iphone retina
ipad
(probably 4 on tomorrow…)

each one has a particular resolution.

Using the magic ofxUI addon, Reza adviced me, in my case, to make 3 GUI.
I guess, about all things related to size in my app that I’d have to create “a kind of” factor variable depending on width/height of the device where the app is running.

Would you do that like I described ?
Is there a better strategy?

2/ Rotation
For my first app, I’ll probably make only one orientation available.
BUT, preparing already another one which would require landscape + portrait available, how can I deal with that in the code?
I mean, as I described for the size: should I integrate that in EVERY variables/classes related to size ?
Or does it exist another way, like to make everything as I do for only one orientation, then to call a global method of UIWindow or whatever to make the rotation ?

Any help would be very appreciated :slight_smile:

Hi Julien,

I build two gui .xib files, one for iPhone and one for iPad.

Add the gui to the GL view, with ofxiPhoneGetGLView(), to allow touch events to reach OF:

  
photoPreview = [[ofxiPhonePhoto alloc] initWithNibName:@"ofxiPhonePhoto" bundle:nil];  
[ofxiPhoneGetGLView() addSubview:photoPreview.view];  

In the gui class, shouldAutorotateToInterfaceOrientation will handle auto-rotating the view. In willAnimateRotationToInterfaceOrientation, you can reposition elements based on portrait / landscape if needed. The ‘autosizing’ alignment controls in the Xcode graphical editor are usually enough that I don’t need to manually reposition the elements.

  
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {    
    return YES;    
}    
  
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration {  
  
	if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {  
  
	} else {  
   
	}  
      
}  

Steve

testing that asap.
many thanks for your answer.

Ok for the 2 xib.
you add the code proposed in the UIViewController I guess.
But where does it test which device & what the size is ?