默认解决方案不合适:
答案 0 :(得分:13)
以下是创建自定义leftBarButtonItem的示例:
UIImage *buttonImage = [UIImage imageNamed:@"backbutton.png"];
UIButton *aButton = [UIbutton buttonWithType:UIButtonTypeCustom];
[aButton setImage:buttonImage forState:UIControlStateNormal];
aButton.frame = CGRectMake(0.0,0.0,buttonImage.size.width,buttonImage.size.height);
[aButton addTarget:self action:@selector(aSelector) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithCustomView:aButton];
self.navigationItem.leftButtonItem = backButton;
希望它有所帮助...
修改强>
试试这个......
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"yourimage.jpg"] style:UIBarButtonItemStyleBordered target:self action:@selector(aSelector)];
self.navigationItem.leftBarButtonItem = backButton;
我不记得按钮是什么类型的按钮,尝试将默认样式更改为其他按钮。祝好运!
答案 1 :(得分:0)
只需创建一个自定义barbuttonitem
并使用类似于后退按钮项的图片进行自定义。
您可以从导航堆栈中的视图控制器获取其文本。
然后处理水龙头以实现所需的效果
答案 2 :(得分:0)
您可以将自定义视图作为条形按钮分配给导航控制器,如下所示:
UIBarButtonItem *customItem = [[UIBarButtonItem alloc] initWithCustomView:yourCustomizedControl];
[yourCustomizedControl release];
self.navigationItem.leftBarButtonItem = customItem;
[customItem release];
如果需要,请查看this Apple documentation以获取更详细的说明。
答案 3 :(得分:0)
这是一个添加后退按钮的黑客:
UINavigationItem* backNavigationItem = [[UINavigationItem alloc] initWithTitle:@"Back"];
[_navigationBar pushNavigationItem:backNavigationItem animated:NO];
[backNavigationItem release];
您可以这样添加更多项目(例如标题,右键):
UINavigationItem *navigationItem = [[UINavigationItem alloc] initWithTitle:@"Title"];
navigationItem.rightBarButtonItem = // Some UIBarButtonItem
[_navigationBar pushNavigationItem:navigationItem animated:NO];
[navigationItem release];