trying to create a Universal app for iOS Devices
I have my iPhone app ready and now i've to make it a Universal app.
I'm doing this..
self.window = [[UIWindow alloc] init];
self.appFrame = [[UIScreen mainScreen] bounds];
self.window.frame = self.appFrame;
UINavigationController *aNav = [[UINavigationController alloc] initWithR开发者_JAVA百科ootViewController:self.myViewController];
aNav.view.frame = self.appFrame;
self.nav = aNav;
[self.window addSubview:nav.view];
[self.window makeKeyAndVisible];
I don't have MainWindow.xib
in my project. I'm creating it programmatically.
So if i use this code to give the frame to the window
self.appFrame = [[UIScreen mainScreen] bounds];
self.window.frame = self.appFrame;
Then it iPad should have (0,0,768,1024)
and iPhone should have (0,0,320,480)
But, if I run my code on iPad simulator it takes self.appFrame
as (0,0,320,480)
Can you guys explain me what's the problem??
and
How can i create a Universal app without using MainWindow.xib
??
Open the Build Settings tab of your target in Xcode and set the Targeted Device Family key to iPhone/iPad. Then your app compiles as native iPad and iPhone application and [[UIScreen mainScreen] bounds]
should return the correct results. Btw, you should use [[UIScreen mainScreen] applicationFrame]
instead of bounds for the window frame!
精彩评论