简体   繁体   中英

creating a universal window-based iphone app without generated xib file

I am trying to create a Window-based Universal app for iPhone/iPad. I used the Window-based template in XCode and it creates the necessary app delegate files for iPhone and iPad, but it also creates a xib file for each device, which I don't want to use -- I want to create my own views programmatically using my own view controllers, so I want to totally ignore the provided xib files.

I deleted the xib files from the project and updated the plist file accordingly to not reference them, thinking that now I can define my own views inside the app delegate, attach them to the window and display them. Not so -- that doesn't work -- my created views are not displayed. So I decided to just change the background color of the window to red and see if that shows -- it doesn't. Tracing code execution does show that this code is executed.

So, what can and should I do? Why is this happening?

Change the

int retVal = UIApplicationMain(argc, argv, nil, nil);

in main.m into

int retVal = UIApplicationMain(argc, argv, nil, @"MyAppDelegate");

Then you have to initialize the window in the AppDelegate:

CGRect screenBounds = [[UIScreen mainScreen] bounds];
self.window = [[[UIWindow alloc] initWithFrame: screenBounds] autorelease];

Then you can add views to the Window.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM