美文网首页
UIAlertController的简单用法

UIAlertController的简单用法

作者: 我的天空蔚蓝色 | 来源:发表于2015-11-23 16:18 被阅读188次

*iOS8之后 新出一个UIAlertController,直到iOS9,之前的UIAlertView和UIActionSheet已完全被废弃,个人感觉UIAlertController比以前的那两个控件好用多了。
上代码:

UIAlertController * alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"你还未绑定手机号" preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
//在这里干你想干的事,不是人
}];
UIAlertAction *otherAction = [UIAlertAction actionWithTitle:@"去绑定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
//在这里干你想干的
BinDingViewController * TVC =[[BinDingViewController alloc]init];
[self.navigationController pushViewController:TVC animated:YES];
}];
// Add the actions.
[alertController addAction:cancelAction];

[alertController addAction:otherAction];

[self presentViewController:alertController animated:YES completion:nil];

以上代码就ok了

相关文章

网友评论

      本文标题:UIAlertController的简单用法

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