Reputation: 2237
I am new to iPhone development. I have been looking at samples and made a sample project, but am stuck.
I am trying to add a view to the AppDelegate class so it will show when the app is launched.
code is as follows
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[window addSubview:viewController.view];
[window makeKeyAndVisible];
}
However this does not show the .xib tied to the viewController but the MainWindow.xib is shown.
I think it is being added since when I shut the app down the content of the desired view is shown as it is shutting down.
I thought the addSubview puts the view in front of all others when called.
Is there something I should do in the Interface Builder to set priorities?
Updated:
By lowering the alpha attribute to 0.0 for the UIWindow for MainWindow.xib made the view that was added by addSubview apear. However this is prob not the right thing to do.
Upvotes: 0
Views: 1733
Reputation: 2237
Ok I found out what was wrong, it was a really careless mistake I made when I was using the Interface Builder.
I mistakenly created the xib to add to the MainWindow.xib as a window.xib and not a view.xib.
Once recreating it as a view.xib everything went fine.
...so embarrassed I have made such a stupid mistake, hope it would be useful to others.
Upvotes: 1
Reputation: 4240
In the interface builder, is the ViewControler is properly bound to the viewController variable in your AppDelegate class?
In your AppDelegate.h, there should be something like, IBOutlet UIViewController *viewController;
In the interface builder, open MainWindow.xib, right click the App Delegate item and see whether some value has been assigned to the viewController attribute. If not, drag the 'dot' to the your ViewController item in interface builder.
Upvotes: 0