gpt4 book ai didi

ios - 如何从 UIActionSheet 以编程方式修改完成按钮?

转载 作者:行者123 更新时间:2023-11-28 22:28:45 25 4
gpt4 key购买 nike

我有这个方法来创建一个操作表和 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,但我想将其修改为 Ready。我该如何实现?

最佳答案

替换:

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 作为样式。

关于ios - 如何从 UIActionSheet 以编程方式修改完成按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18115038/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com