2011-06-22 7 views
0

上AlertViewに問題とキーボードは、私はこの方法IOS:私はテキストフィールド1に書くことが私のキーボードを用意して、このビューを開くとiPadの

- (void)viewWillAppear:(BOOL)animated{ 
[textField1 becomeFirstResponder];} 

、ビューを持っている、そしてそれはすべての権利です。

が、私はアラートビューで「OK」を押したときに、私は単純にアラートビュー

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"ok!" 
                 message:@"It's all right" 
                 delegate:nil 
               cancelButtonTitle:@"OK" 
               otherButtonTitles:nil]; 
    [alertView show]; 
    [alertView release]; 

を表示したときに、私のキーボードが消えて、後に自動的に再表示されます。なぜ私はこの効果がありますか?この効果を残すことはできますか?

答えて

1

はUITextFieldDelegateの方法

- (BOOL)textFieldShouldEndEditing:(UITextField *)textField 

実装例実装してみてください。

- (void)showAlertView 
{ 
    // declared as @property (nonatomic, assign) BOOL shouldHideKeyboard 
    self.shouldHideKeyboard = NO; 

    // code to show alert view here 
    // set the alert view's delegate to self 
} 

- (BOOL)textFieldShouldEndEditing:(UITextField *)textField 
{ 
    return self.shouldHideKeyboard; 
} 

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex 
{ 
    self.shouldHideKeyboard = YES; 
} 
+0

を私は、このメソッドの内部で書くべきか...理解していませんか? – CrazyDev

+0

アラートが表示されているときにテキストフィールドの編集が終了しないようにするため、キーボードは消えません。 – FeifanZ

+0

私はこの問題を解決できません...あなたは例を挙げることができますか? – CrazyDev

関連する問題