如何将基于视图的应用程序转换为基于导航的应用程序

时间:2012-06-07 10:42:43

标签: iphone ios uiviewcontroller uinavigationcontroller

有人可以向我解释将基于视图的应用程序转换为基于导航的应用程序的一步一步过程吗?这是IB和我的appdelegate中为实现这一目标而采取的步骤吗?

2 个答案:

答案 0 :(得分:2)

在您的app委托中,您可以像这样输入代码:

 self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
    [self.window addSubview:navigationController.view];

答案 1 :(得分:0)

在接口文件中添加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];

返回YES;

并且不要忘记将委托连接到IB中的filesowner。

相关问题