在导航栏中添加栏按钮项目
我正在使用导航栏按钮项目。我使用以下代码来执行此操作,
UIBarButtonItem *btnSave = [[UIBarButtonItem alloc]
initWithTitle:@"Save"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(save_Clicked:)];
self.navigationItem.rightBarButtonItem = btnSave;
[btnSave release];
UIBarButtonItem *btnCancel = [[UIBarButtonItem alloc]
initWithTitle:@"Cancel"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(save_Clicked)];
self.navigationItem.leftBarButtonItem = btnCancel;
[btnCancel release];
我的问题是如何在左栏按钮项目旁边添加另一个按钮。 提前致谢
i was working with navigation bar button items.i was using the following code to do so
UIBarButtonItem *btnSave = [[UIBarButtonItem alloc]
initWithTitle:@"Save"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(save_Clicked:)];
self.navigationItem.rightBarButtonItem = btnSave;
[btnSave release];
UIBarButtonItem *btnCancel = [[UIBarButtonItem alloc]
initWithTitle:@"Cancel"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(save_Clicked)];
self.navigationItem.leftBarButtonItem = btnCancel;
[btnCancel release];
my question is how to add another button just adjacent to the left bar button item.
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
为此,您需要创建一个工具栏,然后继续向其中添加 UIButton,然后将工具栏设置为 leftBarButton,
如下所示:
希望对
Pondd有帮助
To do this you need to create a toolbar then keep adding UIButton to it, then set the toolbar as the leftBarButton
something like this:
hope that help
Pondd
创建一个按钮,
将此按钮添加到导航栏右侧
或将此按钮添加到导航栏左侧
doLogout
是一个在触摸注销按钮时调用的函数Create a button as
Add this button to right of navigation bar
or add this button to left side of navigation bar
doLogout
is a function which will be called on touch logout button我通过使用以下代码完成了我的任务:
注意:从 IOS 5.0 开始,苹果已经做得更容易了。可以这样做
I achieved my task by using the following code :
NOTE:From IOS 5.0 onwards, apple has done it lot easier . It can be done as
创建一个带有两个按钮的自定义视图,并使用
UIBarButtonItem
的initWithCustomView:
初始化程序。应该可以做到这一点。Create a custom view with two buttons and use
UIBarButtonItem
'sinitWithCustomView:
initializer. That should do it.