*iOS8之后 新出一個(gè)UIAlertController闭翩,直到iOS9,之前的UIAlertView和UIActionSheet已完全被廢棄,個(gè)人感覺UIAlertController比以前的那兩個(gè)控件好用多了姻几。
上代碼:
UIAlertController * alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"你還未綁定手機(jī)號(hào)" 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了