以编程方式添加UIBarButtonItem的正确方法是什么?在我的情况下,我试图给rightBarButtonItem
添加一个,我一直在围绕控制器层次结构跳跃,但我似乎无法让按钮出现在任何地方。如何以编程方式添加UIBarButtonItem?
这里是我当前的代码:
- (void)viewDidLoad {
[super viewDidLoad];
[self.navigationItem setRightBarButtonItem:[[[UIBarButtonItem alloc] initWithImage:[[UIImage alloc] initWithContentsOfFile:@"Barcode-White.png"] style:UIBarButtonItemStylePlain target:self action:@selector(scanEquipment:)] autorelease]];
}
我希望有人能指引我到正确的方向。我试图调用这个控制器的是3个级别。因此,UITabBarController
- >UIViewController (Settings, 1st level)
- >UIViewController (Vehicle, 2nd level)
- >UIViewController (Inventory, 3rd level)
。
无论如何,在此先感谢您的帮助!
你真棒,我爱你。我从来不会猜到这是造成它失败的图像,我认为我没有使用正确的控制器层次结构。无论如何,感谢您的帮助,它现在可以工作,我也学到了一些东西。 :) – Gup3rSuR4c 2011-03-26 05:32:30
@Alex也爱你。 – peterjb 2011-03-26 08:29:06