質問

Modal UInavControllerの保存ボタンに問題があります。保存ボタンを押すと、キーボードがまだ起きている場合は却下し、テキストフィールドからのデータを検証し、情報を送信している間にUiprogressviewを表示します。

私の問題は、キーボードが十分に速く邪魔にならないので、Uiprogressviewを表示する時が来たときにキーボードがまだ上がっており、私の見解の底に向かって追加され、愚かに見えることです。

Returnキーを押すと、キーボードがドロップしてから、保存を押すことができます。問題はありません。ただし、ユーザーがキーボードの返品キーをスキップして、右上の保存ボタンに合わせて正しく進むと、問題が発生します。

理想的には、それが見えなくなるように短い待機ステートメントを実装したいと思います。または、遅延後に検証を実行しますが、私が試したことは何も機能していません。助けてください。

コード例:

// end edit mode - should kill all keyboards
[[self.tableView superview] endEditing:YES]; 

// make sure everything is entered correctly and validates
[self validateEntryFields]; // keyboard not gone when this finishes

if (valid) { // progress view shows up towards bottom of view
    HUD = [[MBProgressHUD alloc] initWithView:self.view];
    [self.view addSubview:HUD];
    HUD.delegate = self;
    HUD.labelText = @"Adding User";
    HUD.detailsLabelText = @"Please Wait";
    [HUD showWhileExecuting:@selector(sendNewUserInformation) onTarget:self withObject:nil animated:YES];
}
役に立ちましたか?

解決

キーボード通知を使用できます(タイマーに基づくよりも正しいソリューションになります):

[notificationCenter addObserver: self selector: @selector(keyboardDidHide:) name: UIKeyboardDidHideNotification object: nil];

そして、あなたの進捗状況を示します keyboardDidHide: 方法。

他のヒント

わずかな遅延が機能する場合は、検証とIFステートメントの間に次のコードを試してみることができます。

nstimerオブジェクトを使用できます。

[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(mumboJumbo:)userInfo:nil repeats:NO];

コードを次のような方法に追加します。

-(void)mumboJumbo:(id)sender{
    HUD = [[MBProgressHUD alloc] initWithView:self.view];
    [self.view addSubview:HUD];
    HUD.delegate = self;
    HUD.labelText = @"Adding User";
    HUD.detailsLabelText = @"Please Wait";
    [HUD showWhileExecuting:@selector(sendNewUserInformation) onTarget:self withObject:nil animated:YES];
}

私があなたの問題を正しく理解していれば、それが機能するはずです。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top