简体   繁体   中英

define specific TabBarController that isn´t the initial VC in AppDelegate - swift

In my App there is a TabBarController that ins´t the initial VC. I wanted to save the new tab order when the user didEndCustomizingViewControllers . I found a recently asked question: How to: Save order of tabs when customizing tabs in UITabBarController

I used the code of Rickard Elimää which defines the TabBarController as the initial Controller in AppDelegate :

let tabBar: UITabBarController = self.window?.rootViewController as! UITabBarController

For testing whether the code to save the order works I set the TabBarController as the initial Controller and it works. But the UITabBarController should´t be the initial VC. So my question is how to define that TabBarController, so that the code works.

Thanks for any help

I found the best way to do this is to implement UIViewControllerTransitionDelegate . This will handle animation as well as passing the rootViewController. It's a tad more complicated than just passing the rootViewController (as I originally had done), but it was worth the time to switch to this in the long run.

Apple Documentation .

www.raywenderlich.com (an implementation example)

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