gpt4 book ai didi

ios - 让 UIAlertView 保持不变

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

我有一个在 viewDidLoad 中实现的 UIAlertView。当选择 otherButton (buttonAtIndex:1) 时,我试图让 alertView 保持不变。这是我的代码:

UIAlertView *dialog = [[UIAlertView alloc] initWithTitle:@"Title"
message:@"Message:"
delegate:self cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Done", nil];

[dialog setAlertViewStyle:UIAlertViewStylePlainTextInput];
[dialog show];


- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1) return;
[alertView dismissWithClickedButtonIndex:buttonIndex animated:YES];
}

当选择第二个按钮(“完成”)时,alertView 消失。我怎样才能让它留下来?

最佳答案

您应该创建自己的警报 View 类,该类不是 UIAlertView 的子类。 UIAlertView 的文档,它在“子类化注释:”下说:

UIAlertView 类旨在按原样使用,不支持子类化。 (...)

以上内容在 UIAlertView Apple Documentation 中引用标记为子类化注释的部分

关于ios - 让 UIAlertView 保持不变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30798091/

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