gpt4 book ai didi

ios - 如何在他们的Click上更改UIActionSheet Button标题?

转载 作者:行者123 更新时间:2023-12-01 17:16:17 24 4
gpt4 key购买 nike

我在点击UIbutton时显示UIActionSheet。

UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:@"Clock" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Start",@"Reset",nil];
[actionSheet setTag:1001];
[actionSheet showInView:self.view];

[actionSheet release];

我想在单击时更改第一个“开始”按钮的标题。
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch (buttonIndex)
{
case 0:
{
// I want to change title of first button start to stop. on clicking.
}
break;
case 1:
{

}
break;
default:
break;
}

}

需要更改开始按钮标题才能停止,然后再次停止就可以开始。

最佳答案

您可以使用以下代码更改文本。
尝试在.m文件中实施

@interface AudioPlayerDemoViewController ()
{
UIActionSheet *action;
NSString *titleString;
}
@end

@implementation AudioPlayerDemoViewController

- (void)viewDidLoad
{
[super viewDidLoad];
titleString = @"Start";
// Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)actionSheetTap:(id)sender
{
action = [[UIActionSheet alloc]initWithTitle:@"Demo" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:titleString,@"Stop", nil];
[action showFromBarButtonItem:sender animated:YES];

}

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [actionSheet buttonTitleAtIndex:buttonIndex];

if([title isEqual: @"Start"])
{
action = nil;
titleString = @"Pause";

}
if([title isEqual: @"Pause"])
{
action = nil;
titleString = @"Start";

}

}

关于ios - 如何在他们的Click上更改UIActionSheet Button标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18692096/

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