简体   繁体   中英

ios Disable NavigationBar back button

Is it possible to disable temporarily the NavigationBar Back Button?

I manipulate the NavigationController.ViewControllers property and the right place to do it is in ViewDidAppear() . On the other hand, ViewDidAppear() is called quite late since the screen is animated. So a user presses the back button before ViewDidAppear() is called and causes havoc in the synchronization between the stack of view controller and the stack associated with the Back button. If the user waits a bit and ViewDidAppear() gets called, everything works OK. Hence my need to disable temporary the BackButton.

Thank you, donescamillo@gmail.com

Using a delay as suggested in the comments would work but it's not necessarily a good thing to do. You shouldn't really create artificial delays in your code. Different devices will perform your viewDidAppear method at different speeds and you will have to set your delay to wait for the slowest device, artificially reducing the responsiveness for people on faster devices. If you could explain what you're doing fully maybe there is a more appropriate solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM