简体   繁体   中英

How can I make a subclass of UITabBarController inherit from UIViewController too?

I am using a third party SDK which provides a custom UIViewController . I am not sure of the exact functionality since it's closed source.

I want to create a subclass of UITabBarController that also inherits the functionality from the third party UIViewController. Is that possible using Swift ?

No, Swift only supports single inheritance of superclasses, and multiple inheritance of protocols. You could use delegation though - delegate to one of the classes in question. Without knowing your intents, it hard to be more specific. From the face of it though, it feels like a bad idea from the outset, I would look for cleaner high level solution.

You shouldn't need to subclass UITabBarController . Instead create a UITabBarController and set an instance of the custom view controller class as one of it's view controllers:

tabBarController.setViewControllers([viewController], NO)

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