Question

I'm trying to find a quick way to change from an iPhone app to a Universal app (iPhone, iPad) for now. (Later I will refactor app fully for custom views to meet Universal targets.) I read this very good blog post which gives a straightforward way of doing this by first removing hard-coded view sizes, then setting the UIWindow frame to the UIScreen frame - for apps that will utilize only a single view. His sample code was something like this:

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    CGRect  rect = [[UIScreen mainScreen] bounds];
    [self.window setFrame:rect];
}

I put this code in my application didFinishLaunchingWithOptions but I'm still geting the same iPhone view, pushed to top left corner of iPad. Can anyone help with this?

Was it helpful?

Solution

You don't need any ifs, or to change the frame on the window. Instead, when you create the window, use:

window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top