//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
// シングル
//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
NSString *title = NSLocalizedString(@"TITLE", @"タイトル");
NSString *message = NSLocalizedString(@"MESSAGE", @"メッセージ");
NSString *cancelButtonTitle = NSLocalizedString(@"CANCEL", @"キャンセル");
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title
message:message
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:cancelButtonTitle
style:UIAlertActionStyleCancel
handler:nil];
[alertController addAction:cancelAction];
[self presentViewController:alertController animated:YES completion:nil];
// 消去
[self dismissViewControllerAnimated:YES completion:nil];
//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
// パスワード入力
//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
typeof(self) __weak wself = self;
NSString *title = NSLocalizedString(@"TITLE", @"タイトル");
NSString *message = NSLocalizedString(@"MESSAGE", @"メッセージ");
NSString *ok = NSLocalizedString(@"OK", @"OK");
NSString *cancel = NSLocalizedString(@"CANCEL", @"キャンセル");
UIAlertController* alert = [UIAlertController alertControllerWithTitle:title
message:message
preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:cancel
style:UIAlertActionStyleDefault handler:nil]];
[alert addAction:[UIAlertAction actionWithTitle:ok
style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action)
{
UITextField *textField = alert.textFields[0];
[wself.view endEditing:YES];
NSLog(@"%@", textField.text);
[textField resignFirstResponder];
}]];
[alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
textField.placeholder = @"パスワード";
textField.keyboardType = UIKeyboardTypeNumberPad;
textField.secureTextEntry = YES;
}];
[self presentViewController:alert animated:YES completion:nil];
//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
// 複数選択(3以上)
//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
NSString *title = NSLocalizedString(@"TITLE", @"タイトル");
NSString *message = NSLocalizedString(@"MESSAGE", @"メッセージ");
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title
message:message
preferredStyle:UIAlertControllerStyleAlert];
NSString *otherButtonTitle1 = NSLocalizedString(@"BUTTON_1", @"ボタン1");
UIAlertAction *otherButtonAction1 = [UIAlertAction actionWithTitle:otherButtonTitle1
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action)
{
// ボタン1押下時の処理を行う
NSLog(@"ボタン1押下時の処理を行う");
}];
NSString *otherButtonTitle2 = NSLocalizedString(@"BUTTON_2", @"ボタン2");
UIAlertAction *otherButtonAction2 = [UIAlertAction actionWithTitle:otherButtonTitle2
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action)
{
// ボタン2押下時の処理を行う
NSLog(@"ボタン2押下時の処理を行う");
}];
NSString *otherButtonTitle3 = NSLocalizedString(@"BUTTON_3", @"ボタン3");
UIAlertAction *otherButtonAction3 = [UIAlertAction actionWithTitle:otherButtonTitle3
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action)
{
// ボタン3押下時の処理を行う
NSLog(@"ボタン3押下時の処理を行う");
}];
NSString *cancelButtonTitle = NSLocalizedString(@"CANCEL", @"キャンセル");
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:cancelButtonTitle
style:UIAlertActionStyleCancel
handler:nil];
[alertController addAction:otherButtonAction1];
[alertController addAction:otherButtonAction2];
[alertController addAction:otherButtonAction3];
[alertController addAction:cancelAction];
[self presentViewController:alertController animated:YES completion:nil];
//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
// 処理中
//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
NSString *title = NSLocalizedString(@"", nil);
NSString *message = NSLocalizedString(@"", nil);
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title
message:message
preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:alertController
animated:YES
completion:^() // (void (^)(void))completion = ^()
{
UIActivityIndicatorView *indicator = UIActivityIndicatorView.new;
indicator.center = CGPointMake(alertController.view.bounds.size.width/2,
alertController.view.bounds.size.height/2);
indicator.color = [UIColor blackColor];
[indicator startAnimating];
[alertController.view addSubview:indicator];
}];
最終更新:2018年03月12日 15:40