-1

以下のアニメーション コードを呼び出している UITextField があります。正常に動作しますが、リターンキーを押すとこのコードが実行されます。ユーザーがリターンキーを押さずにテキストフィールドにデータを入力すると、このコードが自動的に実行されるようにします。

    - (BOOL)textFieldShouldReturn:(UITextField *)textField
       {
         [patientNameTextField resignFirstResponder];
[addressTextField resignFirstResponder];
         [doctortTextField resignFirstResponder];
     [self showAnimationBack];
         return YES;
    }
4

4 に答える 4

4

データを入力したら、このメソッドを使用できることを意味します。

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
//do something here
return YES;
}

またはこれらの方法を使用します。

- (BOOL)textFieldShouldEndEditing:(UITextField *)textField;          // return YES to allow editing to stop and to resign first responder status. NO to disallow the editing session to end
- (void)textFieldDidEndEditing:(UITextField *)textField;             // may be called if forced even if shouldEndEditing returns NO (e.g. view removed from window) or endEditing:YES called
于 2013-05-28T04:37:02.707 に答える
1

次のデリゲート メソッドを試してください。

- (void)textFieldDidBeginEditing:(UITextField *)textField
- (void)textFieldDidEndEditing:(UITextField *)textField;
于 2013-05-28T04:34:07.180 に答える
0

使用する

- (void)textFieldDidEndEditing:(UITextField *)textField;
{

 [patientNameTextField resignFirstResponder];
 [addressTextField resignFirstResponder];
 [doctortTextField resignFirstResponder];
 [self showAnimationBack];

}
于 2013-05-28T04:34:27.837 に答える