2

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?

andrewz
  • 4,729
  • 5
  • 49
  • 67

1 Answers1

11

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.

dasdom
  • 13,975
  • 2
  • 47
  • 58