【发布时间】:2015-01-16 03:39:25
【问题描述】:
我已将我的 UINavigationController 子类化并尝试设置工具栏项,但它们没有出现。我已经在故事板中为导航控制器设置了类。在视图控制器中,我在 viewDidAppear 方法中设置了 [self.navigationController setToolBarHidden:NO animated:NO]。下面是我在子类中使用的代码。任何帮助都会非常感谢。
@interface FCMapNavigationController ()
@end
@implementation FCMapNavigationController
- (void)viewDidLoad
{
// Call super
[super viewDidLoad];
NSLog(@"Toolbar = %@", self.toolbar);
// Set the toolbar items
UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:@[@"Standard", @"Satellite", @"Hybrid", @"Terrain"]];
//[segment addTarget:self action:@selector(changeMapType:) forControlEvents:UIControlEventValueChanged];
//[segment setSelectedSegmentIndex:self.mapView.mapType - 1];
UIBarButtonItem *seg = [[UIBarButtonItem alloc] initWithCustomView:segment];
UIBarButtonItem *flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
//self.refresh = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refreshData)];
[self setToolbarItems:@[flex, seg, flex]];
}
@end
【问题讨论】:
标签: ios uinavigationcontroller subclass toolbar uitoolbar