IOS Swift summarizes Navigationcontroller problems and how to solve them _ios

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.