Ios 以编程方式创建的UISplitViewController不';没有滑动手势来显示/隐藏主控

Ios 以编程方式创建的UISplitViewController不';没有滑动手势来显示/隐藏主控,ios,objective-c,ipad,Ios,Objective C,Ipad,我在一个非常奇怪的案例中挣扎:我创建了一个UISplitViewController self.splitViewController = [[UISplitViewController alloc] init]; self.splitViewController.presentsWithGesture = YES; UIViewController * master = [[UIViewController alloc] init]; master.view.backgroundColor

我在一个非常奇怪的案例中挣扎:我创建了一个
UISplitViewController

self.splitViewController = [[UISplitViewController alloc] init];
self.splitViewController.presentsWithGesture = YES;

UIViewController * master = [[UIViewController alloc] init];
master.view.backgroundColor = [UIColor yellowColor];
UINavigationController * navMaster = [[UINavigationController alloc] initWithRootViewController:master];

UIViewController * detail = [[UIViewController alloc] init];
detail.view.backgroundColor = [UIColor redColor];
UINavigationController * navDetail = [[UINavigationController alloc] initWithRootViewController:detail];

self.splitViewController.viewControllers = @[navMaster,navDetail];

self.window.rootViewController = self.splitViewController;
[self.window makeKeyAndVisible];

但用于打开/显示主视图控制器的滑动手势(如在Mail应用程序中)在iOS7中不起作用,但在iOS8中起作用。如果我从主/细节模板创建一个新项目,手势就会起作用。但是我需要以编程方式创建
UISplitViewController
,因为我必须在登录页面之后添加一个普通视图控制器。我不想使用storyboard,因为在这个应用程序中它会太大。

我也遇到了同样的问题,我发现了这个关于如何使它工作的很棒的教程:

有了它,您还可以使用大小类,仅使用一个故事板来支持iPhone,并利用iPhone 6+的横向分割视图功能

注意:如果您想使用大小类并且仍然支持iOS 7,则必须使用故事板。(如果按代码使用,则没有向后兼容性)