UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"删除确认" message:nil preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * decideaction = [UIAlertAction actionWithTitle:@"删除" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//此处写点击事件
}];
UIAlertAction * cancelaction = [UIAlertAction actionWithTitle:@"放弃" style:UIAlertActionStyleDefault handler:nil];
[alert addAction:decideaction];
[alert addAction:cancelaction];
Swift UIAlertController 示例
本文提供了一个使用 Swift 语言创建 UIAlertController 的示例代码,展示了如何通过 UIAlertController 显示带有两个按钮(删除和放弃)的警告框,并为删除按钮设置点击事件。
2万+

被折叠的 条评论
为什么被折叠?



