iOS UINavigationBar button remains faded after segue back

前端 未结 4 1778
时光说笑
时光说笑 2020-11-27 20:43

In my app I have multiple view controllers, and most have a right-hand-side UIBarButtonItem with direct \"show\" segue actions attached.

Having segued t

4条回答
  •  北海茫月
    2020-11-27 21:28

    This is a bug in iOS 11.2 and happens because the UIBarButtonItem stays highlighted after navigation and does not return to its normal state after the other view controller pops.

    To avoid this behavior, either

    1. use a UIBarButtonItem with a UIButton as a custom view

    2. disable and re-enable the bar button item in viewWillDisappear(_:) (although this causes the button to appear immediately, use matt's solution to avoid this):

      barButtonItem.isEnabled = false
      barButtonItem.isEnabled = true
      

提交回复
热议问题