我在PickerView上添加了自定义“完成”和“取消”按钮,如:
- (void)customBtnsToPickerView
{
UIToolbar *toolBar= [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
[toolBar setBarStyle:UIBarStyleBlackOpaque];
NSMutableArray *barItems = [[NSMutableArray alloc] init];
UIBarButtonItem *cancelBtn = [[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStyleDone target:self action:@selector(cancelActionOfPickerView:)];
[barItems addObject:cancelBtn];
UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
[barItems addObject:flexSpace];
UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(doneActionOfPickerView:)];
[barItems addObject:doneBtn];
[toolBar setItems:[NSArray arrayWithArray:barItems]];
[self.pickerView addSubview:toolBar];
}
但他们总是处于禁用状态。我不知道里面有什么问题。 我正在使用带有IOS 6.1的iphone 5 ......