Search code examples
iosios6iphone-5

issues with iphone 5 optimization


I'm trying to make my views in my app compatible with the iPhone 5. My storyboard is currently not using autolayout, and when I run it on the iphone 5 simulator or an actual device, all of the backgrounds stretch to fit the screen except for two of them, one of which was set up the same as all of the others that stretch and one of which has an AVVideoPreviewLayer on it. The two that don't stretch have white space on the right side. The ones that do stretch have the backgrounds stretched but the buttons all remain in the place where they would be on a retina 3.5 screen, i.e. shifted over to the left. If I enable autolayout, the buttons all snap to the correct positions but now none of the backgrounds stretch, both the ones that wouldn't stretch before as well as the ones that did.

I haven't been able to find much good information on optimizing the apps for iphone 5. The 4 inch retina launch image is in place in the app summary. If anybody could give me some guidance or point me towards a good resource for figuring this out, I'd really appreciate it.


Solution

  • It ended up making the most sense for me just to have two storyboards, because there were enough differences that doing anything else would have been way too difficult, if not outright impossible. I just threw this in my app delegate didFinishLaunchingWithOptions:

    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
        UIStoryboard *storyBoard;
    
        CGSize result = [[UIScreen mainScreen] bounds].size;
        CGFloat scale = [UIScreen mainScreen].scale;
        result = CGSizeMake(result.width * scale, result.height * scale);
    
        if(result.height == 1136){
            storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone5" bundle:nil];
            UIViewController *initViewController = [storyBoard instantiateInitialViewController];
            [self.window setRootViewController:initViewController];
        }
    }