Creating a universal iphone window application without a xib file

I am trying to create a universal window-based application for iPhone / iPad. I used the Window template in Xcode and creates the necessary application delegation files for iPhone and iPad, but also creates an xib file for each device that I don’t want to use - I want to create my own views programmatically using my own view controllers, so I want to ignore provided xib files.

I deleted the xib files from the project and updated the plist file so as not to refer to them, thinking that now I can define my own views inside the application delegate, attach them to the window and display them. Not so - it does not work - my created views are not displayed. So I decided to just change the background color in the window to red and see if it shows - this is not so. The execution of the trace code indicates that this code has been executed.

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

+2
source share
1 answer

Change

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

in main.m in

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

Then you should initialize the window in AppDelegate:

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

Then you can add views to the window.

+11
source

All Articles