向导航控制器添加第三个按钮

时间:2012-08-22 11:34:52

标签: iphone objective-c ios xcode

我在导航控制器中添加了两个按钮,一个在右键和左键的位置,我想在右键之前添加第三个按钮。怎么做?

 UIButton *logo_btn =  [UIButton buttonWithType:UIButtonTypeCustom];
 [logo_btn setBackgroundImage:[UIImage imageNamed:@"logo-57.png"]  forState:UIControlStateNormal];

[logo_btn setFrame:CGRectMake(-2, 0, 47, 47)];

UIBarButtonItem *btnItem1 = [[UIBarButtonItem alloc] initWithCustomView:logo_btn];
self.navigationItem.leftBarButtonItem = btnItem1;

这就是我在左边添加一个按钮的方法。

1 个答案:

答案 0 :(得分:4)

iOS 5可帮助您在导航栏上创建2个以上的条形按钮

self.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:uibarbuttonInstance1, uibarbuttonInstance2, nil];

右键按钮

self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:uibarbuttonInstance1, uibarbuttonInstance2, nil];