今年開始 Alert view 有新的寫法了。
需要改成用 UIAlertController 的方式去實作,不然就會得到警告喔!
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"刪除" message:@"確定要刪除?" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
//裡面實作
}];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) {
//裡面實作
}];
[alert addAction:sureAction];
[alert addAction:cancelAction];
[self presentViewController:alert animated:YES completion:nil];