在NavigationController中看不到添加按钮(UIButtonBarItem)?

时间:2014-03-20 05:28:23

标签: iphone ios7

实际上我添加了两个按钮(UIButtonBarItem)并将其分配给NavigationItem的右栏按钮,但只有编辑按钮可见,添加按钮不可见但是当我们点击它时会调用它? 知道我的代码http://pastebin.com/Ew4zPEUz

2 个答案:

答案 0 :(得分:2)

尝试在ViewDidload方法

中使用此代码
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0,0,60,30);
[button setImage:[UIImage imageNamed:@"iPhoneBackButton.png"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
self.navigationItem.rightBarButtonItem=barButtonItem;

答案 1 :(得分:0)

终于解决了这个问题。

刚删除下面的行

  self.navigationItem.rightBarButtonItem.tintColor=[UIColor clearColor] 

及其作品:)