How do I add a left bar button without overriding the natural back button?

前端 未结 2 984
执笔经年
执笔经年 2021-01-17 22:08

I have a project that uses UIViewControllers embedded in navigation view controllers, so the back button is automatically set up for me whenever I segue into any detail of m

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-17 22:58

    By default, the leftItemsSupplementBackButton property is false. In this case, the back button is not drawn and the left item or items replace it. If you would like the left items to appear in addition to the back button (as opposed to instead of it) set leftItemsSupplementBackButton to true.

    @property(nonatomic) BOOL leftItemsSupplementBackButton
    

    you can use something like this

    navigationItem.leftBarButtonItem = editButton
    //or
    navigationItem.leftBarButtonItems = [editButton]
    
    self.navigationItem.leftItemsSupplementBackButton = true
    

提交回复
热议问题