我和佩德罗有同样的问题here但对答案不满意,因为已经有赏金和奖励,我创建了这个问题,我会尽快增加赏金。
我想在代码中创建或操作一个 segue(以黄色突出显示),以便主视图是 MFMasterViewController
(以红色突出显示)的多个子类中的任何一个。
When doing this using Nibs I could create a Nib,
SharedNib.xib
& set the class asMFMasterViewController
, then create my subclasses, sayMFMasterViewControllerSubclassA
,MFMasterViewControllerSubclassB
etc. & then instantiate whichever subclass I wanted using...MFMasterViewControllerSubclassA *controller = [[MFMasterViewControllerSubclassA alloc] initWithNibName:@"SharedNib" bundle:nil];
or...
MFMasterViewControllerSubclassB *controller = [[MFMasterViewControllerSubclassB alloc] initWithNibName:@"SharedNib" bundle:nil];
etc.
Any clues as to how I can get this right using storyboards?
我不能对 Pedro 的问题使用提供的答案,我的子类化超出了数据源和委托(delegate)。
最佳答案
您可以将未连接的 View Controller 添加到您的 Storyboard并为它们提供标识符。然后在代码中你可以在你的导航 Controller 子类中做这样的事情:
MFMasterViewControllerSubclassA *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"SubclassA"];
self.viewControllers = @[controller];
这会将导航 Controller 的 Root View Controller 更改为 Controller 。如果你想为变化设置动画,那么你可以使用 setViewControllers:animated: 而不是第二行。
关于ios - 在多个子类之间共享 Storyboard View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13602891/