繁体   English   中英

iPad:没有“弹出按钮”的 UISplitViewController?

[英]iPad: UISplitViewController without “popup button”?

我有一个 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;
}

按钮永远不会出现,我的代码有什么问题? 谢谢

检查aViewController确实具有title属性,如果没有任何字母,则按钮不会出现。

我刚遇到同样的问题,当我硬编码时:

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

按钮出现并工作。

我认为引用导航没有标题,这就是它不起作用的原因。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM