gpt4 book ai didi

ios - 无法为 uialertview 设置标签

转载 作者:行者123 更新时间:2023-11-29 01:35:10 25 4
gpt4 key购买 nike

这是我使用的设置标签的 UIAlertView

 UIAlertView *alertViewDelete = [[UIAlertView alloc] initWithTitle:@"delete User"
message:@"can't restore data after deletion"
delegate:nil
cancelButtonTitle:@"delete"
otherButtonTitles:@"cancel", nil];
alertViewDelete.tag = 97;
[alertViewDelete show];

使用这段代码读取点击的按钮

- (void)alertView:(UIAlertView *)alertView1 clickedButtonAtIndex:(NSInteger)buttonIndex {
if(alertView1.tag == 97)
{
if(buttonIndex == 1)
{
NSLog(@"ok");
}
else
{
NSLog(@"bye");
}
}
}

iOS 应用程序 Objective-C ... 我一遍又一遍地检查这段代码,找不到哪里或哪里做错了。

最佳答案

你忘记了两件事

在 viewcontroller.h 中添加 UIAlertviewDelegate

设置

 alertViewDelete.delegate = self;
alertViewDelete.tag = 97;
[alertViewDelete show];

关于ios - 无法为 uialertview 设置标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33042210/

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