iOS从导航 Controller 子类设置工具栏项目
<p><p>我已将我的 UINavigationController 子类化并尝试设置工具栏项,但它们没有出现。我已经在 Storyboard中为导航 Controller 设置了类。在 ViewController 中,我在 viewDidAppear 方法中设置了 。下面是我在子类中使用的代码。任何帮助都会非常感谢。</p>
<pre><code>@interface FCMapNavigationController ()
@end
@implementation FCMapNavigationController
- (void)viewDidLoad
{
// Call super
;
NSLog(@"Toolbar = %@", self.toolbar);
// Set the toolbar items
UISegmentedControl *segment = [ initWithItems:@[@"Standard", @"Satellite", @"Hybrid", @"Terrain"]];
//;
//;
UIBarButtonItem *seg = [ initWithCustomView:segment];
UIBarButtonItem *flex = [ initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
//self.refresh = [ initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refreshData)];
];
}
@end
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>唯一的 UIViewController 可以影响工具栏项。所以你可以这样解决:</p>
<pre><code>class NavigationController: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
self.topViewController.setToolbarItems([/*your items*/], animated: false)
}
}
</code></pre></p>
<p style="font-size: 20px;">关于iOS从导航 Controller 子类设置工具栏项目,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/27002972/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/27002972/
</a>
</p>
页:
[1]