2

AlertViewController のバックグラウンドでキーボードが表示されない場合textField、私は私の中に 1 つ持っています。しかし、キーボードを閉じると表示されます。これは ios8 デバイスでのみ発生します。ここに私の次のコードがあります: viewControllerAlertViewControllerAlertViewController

 [textField becomeFirstResponder];

 if([self checkIfiOS8])
 {
          // for iOS 8 
          UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Your Title"
                                                                               message:@"Your message" preferredStyle:UIAlertControllerStyleAlert];
          UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { }];
          [alert addAction:cancelAction];
          [self presentViewController:alert animated:YES completion:nil];

 }
 else
 {
           // iOS7
           UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Your Title" message:@"Your message" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
           [alert show];
           [alert release];
 }
4

1 に答える 1

2
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"AlertView" message:@"I am an AlertView" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction * action) {
                                                          [alert dismissViewControllerAnimated:YES completion:nil];
                                                      }];
[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];
于 2014-09-18T08:23:29.923 に答える