嗨朋友我刚刚使用Bellow Code添加了TabbarController
UISplitViewController
和相关的DetailsViewController
: -
-(IBAction)loginclick:(id)sender
{
tabBarController =[[UITabBarController alloc]init];
NSMutableArray *array = [NSMutableArray array];
NSMutableArray *tabArray = [NSMutableArray array];
UISplitViewController *HomeSpilitView = [[[UISplitViewController alloc] init]autorelease];
HomeSpilitViewController *HomeMster = [[HomeSpilitViewController alloc] initWithNibName:@"HomeSpilitViewController" bundle:nil];
UINavigationController *masterNavigationController = [[[UINavigationController alloc] initWithRootViewController:HomeMster] autorelease];
[array addObject:masterNavigationController];
HomeDetailsViewController *HomeDetailsViewControllers = [[HomeDetailsViewController alloc] initWithNibName:@"HomeDetailsViewController" bundle:nil];
UINavigationController *detailNavigationController = [[[UINavigationController alloc] initWithRootViewController:HomeDetailsViewControllers] autorelease];
[array addObject:detailNavigationController];
[HomeSpilitView setViewControllers:array];
[tabArray addObject:HomeSpilitView];
HomeMster.objHomeDetailsViewcontroller = HomeDetailsViewControllers;
HomeSpilitView.delegate = HomeDetailsViewControllers;
array = [NSMutableArray array];
UISplitViewController *splitViewConntroller2 = [[[UISplitViewController alloc] init]autorelease];
REMMasterViewController *viewCont3 = [[REMMasterViewController alloc] initWithNibName:@"REMMasterViewController" bundle:nil];
UINavigationController *masterNavigationController3 = [[[UINavigationController alloc] initWithRootViewController:viewCont3] autorelease];
[array addObject:masterNavigationController3];
REMDetailViewController *viewCont4 = [[REMDetailViewController alloc] initWithNibName:@"REMDetailViewController" bundle:nil];
UINavigationController *detailNavigationController2 = [[[UINavigationController alloc] initWithRootViewController:viewCont4] autorelease];
[array addObject:detailNavigationController2];
viewCont3.detailViewController = viewCont4;
splitViewConntroller2.delegate = viewCont4;
[splitViewConntroller2 setViewControllers:array];
[tabArray addObject:splitViewConntroller2];
// Add the tab bar controller's current view as a subview of the window
[tabBarController setViewControllers:tabArray];
objAppdelegate.window.rootViewController=tabBarController;
}
我在ViewController
中的每个- (id)initWithNibName
中设置了导航标题,如: -
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = NSLocalizedString(@"Detail", @"Detail");
// self.navigationItem.title=@"details"; I am trying with this line code also
// self.tabBarItem.title=@"details";
}
return self;
}
在上面我正在搭建self.navigationItem.title=@"details
,self.tabBarItem.title=@"details
,但我仍然有同样的问题我不知道哪里出错,请指导我并帮助。
谢谢
答案 0 :(得分:2)
在初始化方法中设置标题以查看控制器时,视图控制器不在导航控制器堆栈中。仅当视图控制器位于导航控制器中时,标题才可见。在导航控制器堆栈中添加这些控制器后,设置标题以查看控制器在您使用视图控制器创建导航控制器作为根视图控制器之后。
答案 1 :(得分:1)
<强> SOLVE 强>
在窗口
中添加tabbarController
之前使用刚刚添加的波纹管求解
[[self.tabBarController.tabBar.items objectAtIndex:1] setTitle:NSLocalizedString(@&#34; BotonMapas&#34;,@&#34; comment&#34;)];