UIAlertController的简单用法

2015-11-23  本文已影响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了

上一篇下一篇

猜你喜欢

热点阅读