1

I have a UINavigationController which uses Form Sheet views and I have viewController 1 which pushes viewController2.

viewController2 has a UITextField and the keyboard pops up, great. However upon popping this view and going back to viewController1 the keyboard stays up and I just can't get it to dismiss.

I just want the keyboard to dismiss when returning to viewController1.

4

1 に答える 1

0

viewWillDisappear:メソッドの 2 番目のビュー コントローラーで、次のようにします。

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [textField resignFirstResponder];
}

これにより、テキスト フィールドからフォーカスが奪われ、キーボードが閉じられます。

于 2012-08-27T16:02:05.260 に答える