iphone--UIViewController/UITabBarController和UINavigationController的结合

这两天纠结这两个视图,学习了下别人的源码后,理顺了这个问题,其实也应该也不算是问题了吧,用TabBar建的工程,直接可以从控件库拖个NavigationController就可以,在设置下RootView.

This is not how UINavigationControllers work. You need to set A as the rootViewController of your UINavigationController. UINavigationController is a container for other view controllers.

For example, in your AppDelegate you might do something like this:

UIViewController *A = [[UIViewController alloc] init];    
UINavigationController *navVC = [[UINavigationController alloc] initWithRootViewController:A];
UIViewController *X = [[UIViewController alloc] init];
UIViewController *Y = [[UIViewController alloc] init];
UIViewController *Z = [[UIViewController alloc] init];
UITabBarController *tabVC = [[UITabBarController alloc] init];
tabVC.viewControllers = @[X, Y, Z, navVC];
self.window.rootViewController = tabVC;

And in A

- (IBAction)pressButton:(id)sender
{
    [self.navigationController pushViewController:B animated:YES];
}
from  stack overflow

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    // Override point for customization after application launch.
    // Set the view controller as the window's root view controller and display.
    UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:self.viewController] autorelease];
    self.window.rootViewController = navController;
    [self.window makeKeyAndVisible];

    return YES;
}



employeeDetailed  = [[[EmployeeDetailedViewController alloc] initWithNibName:@"EmployeeDetailedViewController" bundle:nil] autorelease];

[self. navigationController presentModalViewController: navController];
add uinavigationcontroller to uiviewcontroller

self.navigationItem.title=@"Diary Love"; a


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值