开发者

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

开发者 https://www.devze.com 2023-01-30 16:22 出处:网络
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

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, 开发者_如何学Pythonso 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消