SoFunction
Updated on 2025-04-09

iOS swift summary of problems with NavigationController and solutions

IOS swift summarizes problems and solutions for NavigationController

Recently, I have done some iOS projects in Swift language. I have some experience. I have recorded some profound questions to benefit myself and serve everyone.

1. The font color of the status bar after using NavigationController as the container will not be controlled by the system.To set it in the root ViewController in the NavigationController, the code is as follows:

!. = 

For choices, the specific choice depends on the project requirements.

As the problem of failure of the sliding return effect after the container

The situation that causes this problem is that after pushing to the next page in the storyboard, a navigationItem will be automatically generated as the navigation bar. When we drag a button to the navigation bar and return to the button position,

After customizing the return event, the sliding return effect will be invalid

The solution is as follows:

The root ViewController of NavigationController inherits UIGestureRecognizerDelegate, adds it in viewDidLoad()

!.interactivePopGestureRecognizer!.delegate = self

The code of the rewrite method gestureRecognizerShouldBegin() is as follows:

 func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool {
    if (!. == 1){
      return false
    }else{
     return true
    }
  }


Thank you for reading, I hope it can help you. Thank you for your support for this site!