【发布时间】:2012-06-07 10:42:43
【问题描述】:
谁能解释一下将基于视图的应用程序转换为基于导航的应用程序的分步过程?IB 和我的 appdelegate 中为实现此目的而采取的步骤是什么?
【问题讨论】:
标签: iphone ios uiviewcontroller uinavigationcontroller
谁能解释一下将基于视图的应用程序转换为基于导航的应用程序的分步过程?IB 和我的 appdelegate 中为实现此目的而采取的步骤是什么?
【问题讨论】:
标签: iphone ios uiviewcontroller uinavigationcontroller
在您的应用委托中,您可以这样放置代码:
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
[self.window addSubview:navigationController.view];
【讨论】:
在界面文件中添加一个 UInavigation 控制器对象。然后在你的 didfinishlaunch 中添加代码
self.navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
[self.navigationController setNavigationBarHidden:NO];
//self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
//self.navigationController.navigationBar.translucent = YES;
// Override point for customization after app launch
[window addSubview:self.navigationController.view];
[window makeKeyAndVisible];
返回是;
不要忘记将代理连接到 IB 中的文件所有者。
【讨论】: