2011-05-05 66 views
1

我有一個UISplitViewController(完美的工作),我想顯示頂部的按鈕,以縱向模式顯示彈出菜單。iPad:沒有「彈出按鈕」的UISplitViewController?

的AppDelegate代碼

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 

    splitViewController = [[MySplitViewController alloc] init]; 

    MasterViewController *master = [[MasterViewController alloc] init]; 
    PicsTableViewController *detail = [[PicsTableViewController alloc] init]; 

    //create NavigationControllers 
    UINavigationController *masterNav = [[UINavigationController alloc] initWithRootViewController:master]; 
    UINavigationController *detailNav = [[UINavigationController alloc] initWithRootViewController:detail]; 

    [master release]; 

    splitViewController.viewControllers = [NSArray arrayWithObjects:masterNav, detailNav, nil]; 
    [masterNav release]; [detailNav release]; 
    splitViewController.delegate = detail; 
    [detail release]; 

    [self.window addSubview:splitViewController.view]; 
    [self.window makeKeyAndVisible]; 

    return YES; 
} 

PicsTableViewController(代表)代碼:

//add button on top 
- (void)splitViewController:(UISplitViewController *)svc 
    willHideViewController:(UIViewController *)aViewController 
      withBarButtonItem:(UIBarButtonItem*)barButtonItem 
     forPopoverController:(UIPopoverController*)pc 
{ 
    barButtonItem.title = aViewController.title; 
    self.navigationItem.rightBarButtonItem = barButtonItem; 
} 

- (void)splitViewController:(UISplitViewController *)svc 
    willShowViewController:(UIViewController *)aViewController 
    invalidatingBarButtonItem:(UIBarButtonItem *)button 
{ 
    self.navigationItem.rightBarButtonItem = nil; 
} 

按鈕一直沒有出現,這有什麼錯我的代碼? 謝謝

回答

3

檢查aViewController實際上有一個title屬性,如果沒有任何字母那麼按鈕不會出現。

我有同樣的問題,當我硬編碼:

barButtonItem.title = [NSString stringWithFormat:@"hello"]; 

按鈕露面和合作。

我認爲引用導航沒有標題,這就是爲什麼它不工作。