我有这个方法来创建一个动作表和uipicker:
-(void)presentNewPicker{
self.aac = [[UIActionSheet alloc] initWithTitle:@"What City?"
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:@"OK", nil];
self.pickrView = [[UIPickerView alloc] initWithFrame:CGRectMake(0.0, 44.0, 0.0, 0.0)];
self.pickrView.showsSelectionIndicator = YES;
self.pickrView.dataSource = self;
self.pickrView.delegate = self;
self.cityNames = [[NSArray alloc] initWithObjects: @"Phoenix", @"Tahoe", @"Nevada", @"Lime", @"Florida", nil];
UIToolbar *pickerDateToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
pickerDateToolbar.barStyle = UIBarStyleBlackOpaque;
[pickerDateToolbar sizeToFit];
NSMutableArray *barItems = [[NSMutableArray alloc] init];
UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
[barItems addObject:flexSpace];
UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissActionSheet:)];
[barItems addObject:doneBtn];
[pickerDateToolbar setItems:barItems animated:YES];
[self.aac addSubview:pickerDateToolbar];
[self.aac addSubview:self.pickrView];
[self.aac showInView:self.view];
[self.aac setBounds:CGRectMake(0,0,320, 464)];
}
出现的按钮显示为DONE,但我想将其修改为READ,Ready。我该如何做到这一点?
答案 0 :(得分:1)
替换:
UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissActionSheet:)];
使用:
UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithTitle:@"Ready" style: UIBarButtonItemStyleBordered target:self action:@selector(dismissActionSheet:)];
您可能希望使用UIBarButtonItemStyleDone
作为样式。
答案 1 :(得分:1)
我不知道你想做什么,但你可能有兴趣在你的一个uiviews中使用inputView和inputAccessoryView来替换键盘。这将为您提供免费的动画,以及放置工具栏的地方。一些可能有帮助的答案:https://stackoverflow.com/a/6075062/220820
https://stackoverflow.com/a/8583703/220820