Ios 在多个故事板中实现SWRevealViewConroller库(滑出菜单)
我正在尝试实现中给出的Ios 在多个故事板中实现SWRevealViewConroller库(滑出菜单),ios,swift,storyboard,segue,swrevealviewcontroller,Ios,Swift,Storyboard,Segue,Swrevealviewcontroller,我正在尝试实现中给出的SWRevealViewController库,我成功地做到了这一点,但我不希望所有内容都出现在一个故事板上,我希望将其分解为两个故事板 AppDelegate代码: 现在MenuDrawer故事板拥有一切 SWRevealViewCOntroller TableViewController 导航控制器 根视图控制器 以及以下在库中定义的序列: segue1(sw_后方):在SWRevealViewController-->TableViewController之间 seg
SWRevealViewController库
,我成功地做到了这一点,但我不希望所有内容都出现在一个故事板上,我希望将其分解为两个故事板
AppDelegate代码:
现在MenuDrawer故事板拥有一切
segue1(sw_后方):在SWRevealViewController-->TableViewController之间
segue2(sw_-front):在SWRevealViewController之间
-->导航控制器
现在我想要3和4在不同的故事板。但是,当我将3和4移动到不同的故事板时,如何跨故事板创建segue 2我不确定是否理解您的问题,但您可以尝试此操作来检索第二个故事板并从此处加载navigationViewController
let storyBoard : UIStoryboard = UIStoryboard(name: "SecondStoryBoard", bundle:nil)
let deleteViewController = storyBoard.instantiateViewControllerWithIdentifier("SecondNavigationController") as UINavigationController
就我所知,你不需要再按3和4上的第2段。您需要的是参考segue 2上的新视图(3和4)。在Obj-c中,将如下所示:
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
SWRevealViewController *view = [mainStoryboard instantiateViewControllerWithIdentifier:identifier];
[view setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self.navigationController pushViewController:view animated:YES];
其中“self”是创建segue 2的ViewController。
我希望我已经回答了你的问题。首先尝试制作另一个故事板并添加所需内容,然后调用另一个故事板 AppDelegate代码:
func application(application: UIApplication,didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
var storyboard = UIStoryboard(name: "MenuDrawer", bundle: nil)
var storyboard1 = UIStoryboard(name: "NewStoryBoardName", bundle: nil)
var initialViewController = storyboard.instantiateViewControllerWithIdentifier("SWRevealViewController") as! UIViewController
var initialViewController1 = storyboard1.instantiateViewControllerWithIdentifier("SWRevealViewController") as! UIViewController
self.window?.rootViewController = [initialViewController,initialViewController1]
self.window?.makeKeyAndVisible()
return true
}
不能使用Interface Builder在故事板之间创建分段。 这只能通过编程实现,例如:
let storyBoardTwo = UIStoryboard(name: "storyBoardTwo", bundle: nil)
// Pick a view controller using it's identifier string set in Interface Builder.
let myVC = storyBoardTwo.instantiateViewControllerWithIdentifier("aViewController") as! UIViewController // Or use more specific (custom) type
// Push it to the navigation controller
self.navigationController.pushViewController(myVC, animated: true)
pushViewController
只需将myVC
放在顶部即可。这段代码是segue最终要做的事情。您可以将此代码放在现有ViewController中的任何位置、点击按钮iAction或任何需要的地方
如果推送的ViewController有任何分段(从情节提要或代码),它们仍将正常工作
如果您希望以编程方式从同一个情节提要加载ViewController,那么这当然是可行的 我应该把代码放在哪里?[用更多细节更新了我的问题]这似乎很有希望,有一个问题我需要在两个故事板上都安装SWRevealViewController吗??或者是另一个RootViewControlleru,我们必须把它放在这两个位置上。。!!获取行self.window?的2个编译器错误。rootViewController=[initialViewController,initialViewController2]。。。。。。。。1-->“???”不能转换为“UIViewController”。。。。2-->“?”不能转换为“UIViewController”
let storyBoardTwo = UIStoryboard(name: "storyBoardTwo", bundle: nil)
// Pick a view controller using it's identifier string set in Interface Builder.
let myVC = storyBoardTwo.instantiateViewControllerWithIdentifier("aViewController") as! UIViewController // Or use more specific (custom) type
// Push it to the navigation controller
self.navigationController.pushViewController(myVC, animated: true)