美文网首页iOS
ios 弹窗提示

ios 弹窗提示

作者: 若风_412d | 来源:发表于2019-08-21 12:10 被阅读0次

https://www.cnblogs.com/aochitianxia/p/4543315.html

  • (void)use2

{

// 1.创建弹框控制器, UIAlertControllerStyleAlert这个样式代表弹框显示在屏幕中央

UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:@"提示" message:@"点击了头像" preferredStyle:UIAlertControllerStyleAlert];



// 2.添加取消按钮,block中存放点击了“取消”按钮要执行的操作

UIAlertAction *cancle = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {

    NSLog(@"点击了取消按钮");

}];

UIAlertAction *confirm = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {

    NSLog(@"点击了确定按钮");

}];

// 3.将“取消”和“确定”按钮加入到弹框控制器中

[alertVc addAction:cancle];

[alertVc addAction:confirm];



// 4.控制器 展示弹框控件,完成时不做操作

[self presentViewController:alertVc animated:YES completion:^{

    nil;

}];

}

相关文章

网友评论

    本文标题:ios 弹窗提示

    本文链接:https://www.haomeiwen.com/subject/ckebsctx.html