【问题标题】:stop left bar button from being shifted right when back button has no title in navigation bar当后退按钮在导航栏中没有标题时,停止左栏按钮向右移动
【发布时间】:2016-01-18 12:33:45
【问题描述】:

我正在删除导航栏中后退栏按钮的标题:

self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .Plain, target: nil, action: nil)

这很好用,但是,当我向导航栏添加另一个操作的左栏按钮时遇到问题:

self.addLeftBarButtonWithImage(UIImage(named: "menu_lines")!)

左栏按钮显示为从后栏按钮向右移动,就好像后栏按钮仍有标题文本一样。我希望新的左栏按钮位于后退图标“

【问题讨论】:

  • 试试 self.navigationItem.backBarButtonItem = UIBarButtonItem(image: UIImage(named: "menu_lines")!, style: .Plain, target: self, action: nil) 没有第二行
  • 这不是我需要的,因为我想保留后面

标签: ios swift uinavigationcontroller uinavigationbar uinavigationitem


【解决方案1】:

尝试使用self.navigationItem.leftBarButtonItems = [] 添加它们并将 UIBarButton 对象添加到数组中!在这种情况下,您必须设置自己的操作,但它应该注意您要执行的操作

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-12
    • 1970-01-01
    • 1970-01-01
    • 2020-01-08
    相关资源
    最近更新 更多