PopViewController strange behaviour

前端 未结 5 948
忘掉有多难
忘掉有多难 2021-01-20 03:01

Due to a weird request which I tried to turn down but it didn\'t work, I had to override the navigationBar\'s back Button.

I have made a custom UINavigationControlle

5条回答
  •  南笙
    南笙 (楼主)
    2021-01-20 04:01

    I would suggest a completely different approach.

    Create a base class for the view controllers that you are pushing on the navigation stack. In the viewDidLoad method set your custom button as the leftBarButtonItem of the navigationItem and add a -backAction: which invokes the popViewControllerAnimated: method of the navigation controller.

    That way you won't care about things like losing functionality of UINavigationController like the swipe to pop and you won't have to override the navigationBar:shouldPopItem: method at all.

提交回复
热议问题