IOS Swift sums up navigationcontroller problems and how to solve them
Recently used the swift language to do some iOS project, quite some experience, write down some profound problems for their own benefit, to serve everyone
1. The font color of the status bar after Navigationcontroller as a container will not be controlled by the system, to be set in the root Viewcontroller in Navigationcontroller, the code is as follows:
self.navigationcontroller!. Navigationbar.barstyle = Uibarstyle.black
Choice of uibarstyle.black,uibarstyle.default,uibarstyle.blackopaque,uibarstyle.blacktranslucent, depending on the project needs
Failure of sliding return with 2.NavigationController as container
The problem is that the push to the next page in storyboard automatically generates a navigationitem as a navigation bar, when we drag a button to the navigation bar to return to the button's position.
And after you have customized the return event, the sliding return effect is invalidated
The workaround is as follows:
Navigationcontroller root Viewcontroller inheritance uigesturerecognizerdelegate,viewdidload () add
self.navigationcontroller!. interactivepopgesturerecognizer!. delegate = Self
The Gesturerecognizershouldbegin () code for the replication method is as follows:
Func gesturerecognizershouldbegin (gesturerecognizer:uigesturerecognizer)-> Bool {
if ( self.navigationcontroller!. Viewcontrollers.count = = 1) {return
false
}else{return
True
}
}
Thank you for reading, I hope to help you, thank you for your support for this site!