How do I hide/show the right button in the Navigation Bar

前端 未结 18 1985
后悔当初
后悔当初 2020-12-12 19:25

I need to hide the right button in the Navigation Bar, then unhide it after the user selects some options.

Unfortunately, the following doesn\'t work:



        
18条回答
  •  执笔经年
    2020-12-12 20:01

    If you have only one bar button item in the right side you can use this one,

    self.navigationItem.rightBarButtonItem = nil;

    Suppose if you have multiple bar button in the right side, for example suppose you have two bar button items(search button and filter button) in the right side of your navigation item. Now the right bar button items are

    self.navigationItem.rightBarButtonItems = [searchItem,filterItem]

    and you have to hide only search button, you can use like,

    self.navigationItem.rightBarButtonItems = [filterItem]

    Now what happening is, you can completely hide the search button from the navigation item and the filter item comes in the place of search item

提交回复
热议问题