我想在导航栏的左侧有两个按钮,一个是常规后退按钮,另一个是UIBarButtonItem。但是我只能用它来替换默认的后退按钮。我在互联网上尝试过很多代码示例,但无法使用。请帮忙
答案 0 :(得分:2)
不要这样做。它违反了Apple提出的UI指南。 See the paragraph right before figure 6-6 of the iPhone HIG
答案 1 :(得分:0)
据我所知,(目前)UIBarButtonItems
两侧UINavigationBar
都不可能。{/ p>
答案 2 :(得分:0)
是的,你可以通过 -
来做到这一点UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *homeImage = [UIImage imageNamed:@"YOUR_IMAGE.png"];
[backBtn setBackgroundImage:homeImage forState:UIControlStateNormal];
[backBtn addTarget:self action:@selector(YOUR_ACTION)
forControlEvents:UIControlEventTouchUpInside];
backBtn.frame = CGRectMake(0, 0, 69, 26);
UIBarButtonItem *button1 = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
[[self navigationItem] setLeftBarButtonItem:button1];
[button1 release];
button1 = nil;