【发布时间】:2012-08-15 13:29:57
【问题描述】:
我有一个包含 UITabBarController 和 UINavigationController(UITabBarController 的选项卡之一)的类:
@interface HomeController : NSObject{
UINavigationController *maps;
UIBarButtonItem* national;
}
@property (retain, nonatomic) UIWindow *window;
@property (retain, nonatomic) UITabBarController *tabBarController;
@end
在 .m 文件(init 方法)中,这是我正在尝试的方式,但它不起作用:
self.tabBarController.viewControllers = [NSArray arrayWithObjects:adminController, maps, sitesController, nil];
我想将国家按钮作为我的 UINavigationController *maps 的 rightBarButtonItem,所以我在 init 方法(.m 文件)中插入了这些行:
national= [[UIBarButtonItem alloc] initWithTitle:@"national" style:UIBarButtonItemStyleDone target:nil action:nil];
maps.navigationItem.rightBarButtonItem = national;
[national release];
因为我的类不是在 viewDidLoad 方法中插入代码的视图(NSObject 的子类)。
【问题讨论】:
-
你的属性合成了吗?
-
我在(地图类)的 viewDidLoad 中插入了该代码,它起作用了,我没有删除问题,因为它可能有一天会帮助某人。
-
如果您找到了解决方案,请为您的问题添加一个解释它的答案。
标签: iphone ios uinavigationcontroller uitabbarcontroller uinavigationbar