简体   繁体   中英

View based delegation in storyboards and UITabbarController

I know this has been asked, but I can't figure out how to make this work with my app -- I'm sure I'm doing it wrong.

I have two view controllers embedded inside a UITabBarViewContoller , FirstViewController and SecondViewController . SecondViewController is nothing more then a few UITextFields for managing a hostname and port that the app connects to.

FirstViewController contains most of the code (which I know isn't very MVC oriented). I'm trying to implement Delegation from SecondViewController back to FirstViewController ( Passing Data between View Controllers ) but it seems like my delegate methods aren't being called. Since this is based on storyboards, I'm not creating the instance of SecondViewController and I'm not sure how to set the Delegate. Is there a way to access the instance of SecondViewController so I can set the Delegate?

milesper thank you!

My solution (in swift)

    let secondView = self.tabBarController.viewControllers[1] as SecondViewController
    secondView.delegate = self

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