Storyboard中有两个 UIViewController(A 和 B)。 A View Controller 有一个属性
@property (nonatomic, retain) IBOutlet UIViewController *viewController;
我想通过 Storyboard链接到 B。
socket 显示在 Storyboard菜单中的 IBOutlets 部分下,但我无法链接。 为什么我要这样做似乎很奇怪,但我需要它。有人知道怎么做吗?
最佳答案
IBOutlets 是单个 View Controller 中的连接。在 View Controller 中创建对对象的引用,以便您可以在代码中使用这些对象。
您不能从一个 View Controller 创建 IBOutlets 到另一个 View Controller 。属性是正确的方法,但您必须在代码中分配属性。通常,当一个 View Controller 创建另一个 View Controller 时,它可能会设置对自身的引用。
OtherViewController *otherViewController = [OtherViewController alloc] init];
otherViewController.masterViewController = self;
// at this point "otherViewController" has a reference to the current view controller
关于ios - 无法将 UIViewController IBOutlets 与 StoryBoard 链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14217182/