2014-10-08 68 views
0

我掙扎在一個非常奇怪的情況:我創建了一個UISplitViewControllerUISplitViewController創建程序沒有滑動手勢顯示/隱藏主

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]; 

,但(在郵件應用程序等)的滑動手勢打開/顯示主視圖控制器不適用於iOS7,但適用於iOS8。如果我從主/細節模板創建一個新項目,該手勢起作用。但我需要以編程方式創建UISplitViewController,因爲我必須在正常視圖控制器的登錄頁面後添加。我不想使用故事板,因爲在這個應用程序中會太大。

回答

1

我遇到同樣的問題,發現如何使它工作這真棒教程:New UISPlitViewController and iOS7

有了這個,你也可以使用尺寸等級,並且只使用1個故事板,支持iPhone以及走iPhone的優勢6+橫向分割視圖功能。

注意:如果要使用Size Classes並且仍然支持iOS 7,則必須使用Storyboard。(如果通過代碼使用它們,則不存在向後兼容性)