尝试将UISegmentedControl
添加到UINavigationController
工具栏
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.navigationController.toolbarHidden = FALSE;
UIBarButtonItem *test1 = [[UIBarButtonItem alloc] initWithTitle:@"Groups"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(done)];
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:@[@"Groups", @"Regions", @"Objects"]];
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
[self setToolbarItems:[NSArray arrayWithObjects:test1, segmentedControl, nil]];
}
这会导致错误:
-[UISegmentedControl view]: unrecognized selector sent to instance 0x295623c0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UISegmentedControl view]: unrecognized selector sent to instance 0x295623c0'
如果我省略UISegmentedControl
,则加载正常。
我做错了什么?