UIAlertView在IOS 8以上版本已经过时了,官方推荐我们使用UIAlertController代替UIAlertView、UIActionSheet
1、UIAlertController显示普通的Alert
- (IBAction)showAlert:(UIButton *)sender {
//显示提示框
//过时
// UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"message" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"ok", nil];
// [alert show];
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Title"
message:@"This is an alert."
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
//响应事件