0
我有一個UISegmentedControl,我想要出現在UIToolbar中。它出現了,但點擊它不會調用它應該的方法。我錯過了什麼?UISuttonBarItem中的UISegmentedControl
代碼:
-(void)setupToolbars{
NSArray *segItemsArray = [NSArray arrayWithObjects: @"List", @"Day", @"Month", nil];
segmentedControl = [[UISegmentedControl alloc] initWithItems:segItemsArray];
segmentedControl.selectedSegmentIndex = 2;
[segmentedControl addTarget:self action:@selector(changeView) forControlEvents:UIControlEventTouchUpInside];//this line should make the segmented control call the correct method
UIBarButtonItem *segmentedControlButtonItem = [[UIBarButtonItem alloc] initWithCustomView:(UIView *)segmentedControl];
NSArray *barArray = [NSArray arrayWithObjects: todayButtonItem,flexibleSpace, segmentedControlButtonItem, flexibleSpace, nil];
[bottomToolbar setItems:barArray];
}
-(void)changeView{
NSLog(@"changeView");
...
}