问题描述
我有一个针对两个目标的应用程序,分别适用于iPhone和iPad.
I have an app with two targets, for iPhone and for iPad.
该项目未使用尺寸等级.
This project is not using size classes.
在iPhone版本上,我有一个情节提要,其中包含一个名为"termsAndConditions"的viewController.该viewController具有类文件termAndConditions.h和.m.
On the iPhone version I have a storyboard that contains a viewController called "termsAndConditions". This viewController has class files termsAndConditions.h and .m.
在termsAndConditions.m内部,我有一个链接到viewController上的textView的插座.
Inside termsAndConditions.m I have an outlet linked to a textView on the viewController.
然后,我有了iPad的第二个目标.我在那里有一个相同的viewController,称为"termsAndConditions".我的想法是将iPhone版本中的相同类文件termAndConditions.h和.m与另一个目标一起使用.但是有一个问题.
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.
还记得插座指向iPhone故事板的viewController上的textView吗?当我为iPad的termAndAndditions viewController分配使用相同的iPhone类文件时,它显然可以工作,但是当我尝试在iPad版本上访问textView时,什么也没发生.另一方面,当我将鼠标移到实现的插座上时,两个情节提要板上的两个viewControllers上的textViews都会突出显示.
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.
显然,类文件出口确实链接到不同情节提要板上的两个textView,但这似乎是假的.
Apparently the class file outlet is really linked to both textViews on different storyboards, but this appears to be fake.
是否有办法做到这一点,或者我必须在iPad故事板上使用其他名称复制termAndConditions.h和.m?这似乎是一个愚蠢的解决方案.
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.
谢谢.
推荐答案
每个视图控制器可以将1个对象连接到您的类.仔细检查您是否正确设置了类;我经常不小心自动完成了不正确的课程.前任. TermsAndConditionsTableViewController
代替TermsAndConditionsViewController
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
此IBOutlet已连接到三个不同的视图,并为我正常工作.单击该点以显示连接.有时您需要重新建立连接(很少但确实会发生).
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).
这篇关于IBOutlet到两个情节提要板上的两个viewControllers ...是可能的吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!