2012-11-20 89 views
3

我有一個UITabBarController應用程序,其中一個選項卡顯示應用程序設置。這是一個具有多個細節控制器的UISplitViewController,根據主控上選擇的內容將其更改。我detailViewControllers有這些線,允許主視圖,不斷顯示(或應該):iPad 5上的iOS 5 UISplitViewController在縱向上不顯示MasterView(但僅在最初)

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    self.splitViewController.delegate = self; 
} 

- (BOOL) splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation { 
    return NO; 
} 

這裏是我的問題:如果墊是設置選項卡被竊聽的畫像,只是初步的細節圖。不是主人。旋轉墊橫向和背部,主顯示得很好,並停留在那裏。

我不明白爲什麼會發生這種情況。在我更新detailController以不隱藏主控之後,XCode 4.5.2主/明細模板項目沒有這個問題。

任何想法?

回答

1

爲了解決這個問題,我不得不做同樣的代碼,我在原來的問題中使用,但把它放到一個子類UISplitViewController。本來我是把它放到細節視圖中。

+0

你真棒,你應該知道它。非常感謝! – Dumoko

3

我只是有同樣的問題,但通過仔細檢查我的UISplitViewController委託在適當的時候被設置了。

注意什麼在Xcode的樣本項目的AppDelegate中完成,其中該正常工作:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    // Override point for customization after application launch. 
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { 
     UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController; 
     UINavigationController *navigationController = [splitViewController.viewControllers lastObject]; 
     splitViewController.delegate = (id)navigationController.topViewController; 
    } 
    return YES; 
} 

這是UISplitViewController委託專門設置爲特定視圖控制器。

出於我的目的,我將AppDelegate設置爲SplitViewControllerDelegate,因爲我在SplitViewController中進行了一些稍微複雜的viewcontroller管理。

因此,請確保代理在應用程序中正確設置:didFinishLaunchingWithOptions:並且您應該沒有問題。

+0

在使用其他應用程序時,我找到了我的答案。見下文。 –

+0

今天我看到了一些與我試圖更新的非常舊的代碼相同的東西。我必須確保委託在視圖控制器被添加到分割視圖之前被設置(就像我說的,它是舊代碼)。一旦我這樣做,它運作良好。 –

0

簡單的修復,我發現這個問題是要確保AppDelegate中有定向委託:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return YES; 
} 
0

我知道一切都太遲了,但我想告訴我從這個所以別人怎麼逃脫可以採取的好處。

- (IBAction)hideMaster 
{ 
    // 1. set desired width for master view 
    [self.splitViewController setValue:[NSNumber numberWithFloat:0.0] forKey:@"_masterColumnWidth"]; 

    // 2. splitViewController delegate to self 
    self.splitViewController.delegate = self; 

    // 3. give a smooth animation 

    [UIView animateWithDuration:1.0 animations:^{ 
     [self.splitViewController.view layoutSubviews]; 
    }]; 
} 

- (BOOL)splitViewController: (UISplitViewController*)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0); 
{ 
    return NO; 
} 
相關問題