IBOutlet to two viewControllers on two storyboards… is that possible

穿精又带淫゛_ 提交于 2019-12-11 04:05:58

问题


I have an app with two targets, for iPhone and for iPad.

This project is not using size classes.

On the iPhone version I have a storyboard that contains a viewController called “termsAndConditions”. This viewController has class files termsAndConditions.h and .m.

Inside termsAndConditions.m I have an outlet linked to a textView on the viewController.

Then I have the second target for iPad. I have the same viewController there called “termsAndConditions”. My idea was to use the same class files termsAndConditions.h and .m from the iPhone version with this other target. But there is a problem.

Remember that the outlet is pointing to the textView on the viewController of the iPhone storyboard? When I assign the iPad termsAndConditions viewController to use the same iphone class files, it apparently works, but when I try to access the textView on the iPad version nothing happens. On the other hand, when I pass the mouse over the outlet on the implementation, textViews on both viewControllers, on both storyboards, highlight.

Apparently the class file outlet is really linked to both textViews on different storyboards, but this appears to be fake.

Is there a way to do that or will I have to duplicate the termsAndConditions.h and .m with another name to use on the iPad storyboard? This appears to be a stupid solution.

thanks.


回答1:


You may connect 1 object to your class per view controller. Double check that you set the classes correctly; I often accidentally autocomplete the incorrect class. Ex. TermsAndConditionsTableViewController instead of TermsAndConditionsViewController

This IBOutlet is connected to three different views and works correctly for me. Click on the dot to show the connections. Sometimes you need to make the connections again (rare but does happen).



来源:https://stackoverflow.com/questions/27449771/iboutlet-to-two-viewcontrollers-on-two-storyboards-is-that-possible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!