【objective-c】アラート ios objective-c
今更ながらobjective-cでのアラートをメモ。
よく忘れるので。
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"タイトル" message:@"メッセージ?" preferredStyle:UIAlertControllerStyleAlert]; [alert addAction:[UIAlertAction actionWithTitle:@"キャンセル" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }]]; [alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { // ボタンを押した場合の処理を記述する }]]; [self presentViewController:alert animated:YES completion:nil];