How to change/add view to rootcontroller's view in UINavigationController
I have an application where I need to have a "custom" setting page开发者_开发技巧. In my delegate I add a UINavigationController's view to the window with a UIViewController as rootviewcontroller.
In the rootviewcontroller I want to have a button and when I press the button the whole view changes to the settingview that I made. I only need the code to change view.
Thanks for the help in advance.
If Settings View a UIView SubClass then In the Button Action method you can do something like this:
[self.view addChild: settingsView]; //provided that settingsView is already allocated.
If you have written down a separate UIViewController SubClass for Settings then you can do something like this in your Button Action Method:
SettingsViewController *controller=[[SettingsViewController alloc]initWithNibName:@"SettingsViewController" bundle:nil];
[self.navigationController pushViewController:controller animated:YES];
[controller release];
精彩评论