Bronze Challenge done - can you scale the ipad view in xibs?


#1

You can scale the iPad simulator, which is handy for running on my 15" MacBook Pro…

But there’s no way that I can find to scale the Interface Builder, at least not for XIB files… or does anyone have a solution?

Anyway, I was able to do this challenge almost entirely by making a WhereamiViewController~ipad.xib file.

Trap for the unwary, the character before the word “ipad” here is the tilde character, [size=150][color=#BF0000]~[/color][/size], not the hyphen.

I changed the layout a bit of the elements for the iPad version, naturally the MKMapView now takes up the entire iPad screen, and not just a small rectangle on it. I put all the elements (location, activity indicator, and 3-way-segmented control), towards the top of the iPad screen. Then I used the positioning controls to set these items to stay relatively where they were (one in the centre, one on the left, one on the right), despite changes.

Then I added the “autorotation” method to the WhereamiViewController.m file:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { return YES; } else { return (toInterfaceOrientation == UIInterfaceOrientationPortrait); } }
This way, the app works on the iPhone as normal (portrait only), but works on the iPad in both portrait and landscape.


#2

Brilliant solution!
Unfortunately for me, i didn’t realize this was possible and ended up re-writing the entire app! But I learned a TON!
:slight_smile:


#3

I found i didn’t need to create a new Xlb file.
i just used the following code:


-(void) viewDidLoad
{
    
    [worldView setShowsUserLocation:YES];
    [worldView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
    [self.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
    [locationTitleField setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
    [segmentedControl setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleTopMargin];
}

this and setting the XIB file to autosize did the trick.


#4

Am I missing something here? I simply set the target for Universal and everything looks like it’s supposed to on the iPad simulator?

Jeff