6

標準の TextField に「ダーク」スタイルのキーボードを使用しています。これは、ログイン テキスト フィールド、または「パスワードを忘れた」テキスト フィールド用で、ユーザーが情報を入力して送信し、成功すると、通常は標準のナビゲーション コントローラー popViewControllerAanimated: によって別のビューに送信されます。間に AlertView が表示される場合があります。

私が多く見た問題は、キーボードが開いていて、通常の「暗い」灰色であり、ユーザーが [送信] をクリックすると、警告ビューが表示される場合があり、それを閉じると、ビューが次の画面に移動します。前のキーボードが画面から消えます。新しい画面では、別のデフォルト スタイルのキーボードが上にスライドして消えてしまう場合とそうでない場合があります (テキスト フィールドがフォーカスされていなくても!)。次に、別のテキストフィールドをクリックするか、前のビューに戻ってテキストフィールドをクリックすると、この黒いキーボードと白いキーが誤って表示されます。数回クリックした後、何かが通常の濃い灰色に戻るまで、テキストフィールドに表示され続けます。

popViewController が発生する前に、さまざまな方法で元のキーボードを閉じようとしましたが、役に立たないようです。間に AlertView が表示される場合は、popViewController を AlertView ボタンをクリックしたときのデリゲート アクションに結び付けました。キーボードは通常、押す前に離れるほど速くは消えません。遅れはそれを助けません。

編集: ここではアラートビューが明確な原因のようで、何らかの方法でポップとキーボードを妨害しています。

-(BOOL) textFieldShouldReturn:(UITextField *)textField{
    [textfield resignFirstResponder];
    [self.view endEditing:YES];
    return YES;
}

-(IBAction)submitRequest {
    [textfield resignFirstResponder];
    [self.view endEditing:YES];

    // make API call, if call succeeds run this block {
         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"..."
                                                message:@"..."
                                               delegate:delegate
                                      cancelButtonTitle:@"OK"
                                      otherButtonTitles:nil, nil];
          dispatch_async(dispatch_get_main_queue(), ^{
            [alert show];
          });         
    // }
}

// delegate after alert OK is pressed
- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
  [self.navigationController popViewControllerAnimated:YES];
}

この白黒キーボードを回避するにはどうすればよいですか?

ここに画像の説明を入力

4

1 に答える 1

3
Try using the below code. It works fine for iOS 8 and below version

    if (IS_OS_8_OR_LATER) {
            UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert];

            UIAlertAction *cancelAction = [UIAlertAction
                                       actionWithTitle:B_title
                                       style:UIAlertActionStyleCancel
                                       handler:^(UIAlertAction *action)
                                       {
                                           [self.navigationController popViewControllerAnimated:YES];

                                       }];
        [alertVC addAction:cancelAction];
        [self presentViewController:alertVC animated:YES completion:nil];
        }
        else{
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
            [alert show];
        }
}
于 2016-05-27T13:30:59.320 に答える