Storyboard - How to segue to a SplitViewController from a Viewcontroller in navigation based application

大兔子大兔子 提交于 2021-02-08 09:51:22

问题


I have a navigation controller based iPad application. I am using storyboards for the app design. From one of the ViewControllers in the Navigation stack, I need to segue to a screen showing splitviewcontroller. how to I go about that ?

Thanks in advance for any help on this.


回答1:


A UISplitViewController must always be the first/main view controller you use. You can't use it from a UINavigationController or a UITabBarController or similar.




回答2:


I had the exact same problem and I solved it by implementing a custom segue.

@implementation LoginSegue
- (void) perform {
    NSLog(@"Do the segue you way");
    UIViewController *src = self.sourceViewController;
    UIWindow *window = src.view.window;
    [window addSubview:[self.destinationViewController view]];
    window.rootViewController = self.destinationViewController;
}
@end

This seems to have worked for me. I hope this is an acceptable solution when I submit the code to apple.



来源:https://stackoverflow.com/questions/9389073/storyboard-how-to-segue-to-a-splitviewcontroller-from-a-viewcontroller-in-navi

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