gpt4 book ai didi

ios - 如何使用操作表执行文本字段的重置?

转载 作者:行者123 更新时间:2023-11-28 18:17:03 24 4
gpt4 key购买 nike

我想在按下操作表破坏性按钮时将 myview 的文本字段重置为空。完成按钮调用操作表。这是我的操作表:

- (IBAction)submit:(id)sender {
UIActionSheet *sheet=[[UIActionSheet alloc]initWithTitle:@"Options" delegate:sender cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Reset" otherButtonTitles:@"Save", nil];
[sheet showInView:self.view];
}

并使用此方法重置:

- (void)sheet:(UIActionSheet *)sheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex==0)
{
self.textf1.text = @"";
}
}

但什么也没有发生。

enter image description here

enter image description here

最佳答案

delegate:sender 替换为 delegate:self 这就是委托(delegate)的原因

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex

没有得到调用也更新委托(delegate)函数,完成后只需将所有 textFiled 设置为 .text= @""。我希望它会起作用

之前也作为评论发布。

关于ios - 如何使用操作表执行文本字段的重置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34408780/

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