Hiding UINavigationItem's bar button

后端 未结 11 991
粉色の甜心
粉色の甜心 2021-01-04 07:04

I have added a BarButton item to the left of the nav.bar through Interface Builder and in the code I want this only to show in my table view\'s edi

11条回答
  •  攒了一身酷
    2021-01-04 07:13

    Well making it nil was not a option because i wanted to show it again and didnt want to create a button again.

    so what i did was

     UIBarButtonItem *barButton =  (UIBarButtonItem *)self.navBar.topItem.leftBarButtonItem;
     barButton.customView.hidden = true;//Hide
     barButton.customView.hidden = false;//Show
    

    Works for me. (my leftBarButtonItem was created using customView)

    Hope it helps.

提交回复
热议问题