Rud*_*ger 1 iphone objective-c uitabbarcontroller uinavigationcontroller
我现在有一个UITabBar有5个屏幕,调用UIViews.这部分工作正常但我想在其中几个中放入一个UINavigationController.我找到了一些工作正常的教程,但是所有这些教程都在IB中实现,我希望尽可能避免这种情况.
我迷失了在哪里实现UINavigationController,我应该在App Delegate中使用UITabBar并从UIView调用导航控制器,还是应该在UIView类中创建它?
我尝试了大约8种不同的方式,最终导致Navbar无法正常工作,根本没有导航栏或应用程序崩溃.
目前我创建了这样的标签栏:
tabBarController = [[UITabBarController alloc] init];
ScreenA *screenA = [[ScreenA alloc] initWithNibName:@"ScreenA" bundle:nil];
//more here
tabBarController.viewControllers = [NSArray arrayWithObjects:screenA, ...., nil];
[window addSubview:tabBarController.view];
Run Code Online (Sandbox Code Playgroud)
在initWithNibName中我有这个:
self.title = @"Screen A";
self.tabBarItem.image = [UIImage imageNamed:@"someImage.png"];
Run Code Online (Sandbox Code Playgroud)
好的,这样做......
tabBarController = [[UITabBarController alloc] init];
searchTableViewController = [[SearchTableViewController alloc] init];
UINavigationController *searchTableNavController = [[[UINavigationController alloc] initWithRootViewController:searchTableViewController] autorelease];
[searchTableViewController release];
searchMapViewController = [[SearchMapViewController alloc] init];
UINavigationController *mapTableNavController = [[[UINavigationController alloc] initWithRootViewController:searchMapViewController] autorelease];
[searchMapViewController release];
tabBarController.viewControllers = [NSArray arrayWithObjects:searchTableNavController, mapTableNavController, nil];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3131 次 |
| 最近记录: |