开发者

iPad: UISplitViewController without "popup button"?

开发者 https://www.devze.com 2023-03-02 18:42 出处:网络
I\'ve a UISplitViewController (perfectly working) and I would like to display the button on top to display the popup menu in portrait mode.

I've a UISplitViewController (perfectly working) and I would like to display the button on top to display the popup menu in portrait mode.

AppDelegate code

- (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];
    [maste开发者_运维知识库rNav release]; [detailNav release];
    splitViewController.delegate = detail;
    [detail release];

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

    return YES;
}

PicsTableViewController (delegate) code:

//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;
}

The button never shows up, what's wrong with my code ? Thanks


Check that aViewController actually has a title property, if there aren't any letters then the button does not appear.

I just had the same problem and when I hardcoded:

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

the button showed up and worked.

Me thinks that the referencing navigation doesnt have a title, thats why its not working.

0

精彩评论

暂无评论...
验证码 换一张
取 消