Iphone 如何在UIDABBarController中向UINavigationController添加右按钮?
我有一个类,它包含一个UITabBarController和一个UINavigationController(UITabBarController的一个选项卡): 在.m文件(init方法)中,这是我尝试的方法,但不起作用:Iphone 如何在UIDABBarController中向UINavigationController添加右按钮?,iphone,ios,uinavigationcontroller,uitabbarcontroller,uinavigationbar,Iphone,Ios,Uinavigationcontroller,Uitabbarcontroller,Uinavigationbar,我有一个类,它包含一个UITabBarController和一个UINavigationController(UITabBarController的一个选项卡): 在.m文件(init方法)中,这是我尝试的方法,但不起作用: self.tabBarController.viewControllers = [NSArray arrayWithObjects:adminController, maps, sitesController, nil]; 我想将national按钮作为我的UINavig
self.tabBarController.viewControllers = [NSArray arrayWithObjects:adminController, maps, sitesController, nil];
我想将national按钮作为我的UINavigationController*映射的rightBarButtonItem,因此我在init methode(.m文件)中插入该行:
因为我的类不是在viewDidLoad方法中插入代码的视图(NSObject的子类)。映射本身不是viewController,而是管理视图的容器对象。在某些情况下,贴图有一个或多个ViewController-它应该始终有一个rootViewController。所以试试这个:
...create and initialize maps
UIViewController *firstView = maps.rootViewController;
firstView.view; // force it to load its view, may or may not be necessary
firstView.navigationItem.rightBarButtonItem = national;
你合成了你的属性吗?我在(maps’class)的viewDidLoad中插入了代码,它起作用了,我不会删除这个问题,因为它可能有一天会帮助某人。如果你找到了解决方案,请为你的问题添加一个解释它的答案。
national= [[UIBarButtonItem alloc] initWithTitle:@"national" style:UIBarButtonItemStyleDone target:nil action:nil];
maps.navigationItem.rightBarButtonItem = national;
[national release];
...create and initialize maps
UIViewController *firstView = maps.rootViewController;
firstView.view; // force it to load its view, may or may not be necessary
firstView.navigationItem.rightBarButtonItem = national;