1,取消、肯定code
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"你肯定刪除該消息?" preferredStyle:UIAlertControllerStyleAlert]; [alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]]; [alertController addAction:[UIAlertAction actionWithTitle:@"肯定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { Log(@"肯定"); }]]; [self presentViewController:alertController animated:YES completion:nil];
2.彈出框it
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"哈哈消息" delegate:self cancelButtonTitle:@"肯定" otherButtonTitles:nil]; [alert show];