将信息按钮添加到UITabBarController的更多屏幕

Sea*_*ins 1 iphone uitabbarcontroller

我正在尝试将"信息"按钮添加到UITabBarController生成的"更多"屏幕,当您有超过5个选项卡时.我正在使用的代码是这样的:

// Add the info button to the more controller
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
UIBarButtonItem *infoBarButton = [[[UIBarButtonItem alloc] initWithCustomView:infoButton] autorelease];
tabBarController.moreNavigationController.navigationItem.leftBarButtonItem = infoBarButton;
Run Code Online (Sandbox Code Playgroud)

这种事情似乎可以与其他UIViewControllers一起使用,但在这种情况下,代码构建并运行正常,但按钮永远不会出现.

知道可能需要改变什么才能让它发挥作用?

Sea*_*ins 5

啊哈!我需要访问moreNavigationController堆栈中的第一项,而不是moreNavigationController本身.

tabBarController.moreNavigationController.topViewController.navigationItem.leftBarButtonItem = infoBarButton;
Run Code Online (Sandbox Code Playgroud)