开发者

Multiple UIText fields with Multiple UIPickerViews in UITableView

I have a grouped style UITable开发者_StackOverflow社区View with a HeaderView that is loaded from another .xib.

The HeaderView has 4 UITextFields in it:

  • 2 of the fields should display the Keyboard and allow user input.
  • 2 of the fields should display a UIPickerView and update the UITextField with selection.

The Main TableView (with the sections and rows) is filled with UITextFields as well.

  • The UITextField in the first section (indexpath.section = 0) displays a UIPickerView
  • All other UITextFields in the rest of the sections/rows should display the Keyboard

I can get the Keyboard to display correctly and dismiss when the Done button is touched for all the UITextFields that can display the keyboard.

I can get the UIPickerView to display correctly and dismiss (with Custom Save/Cancel buttons).

The problem I have is when mixing the two...

When I do the following I have a hybrid effect:

Step 1: Touch the first UITextField to begin to enter data with the Keybard. Step 2: Enter some data in the UITextField. Step 3: Touch a UITextField that displays a UIPickerView instead of the Keyboard.

The result is the Keyboard AND my custom UIPickerView being displayed at the same time with the Keyboard actually displaying ON TOP of my UIPicker!

Any suggestions on how to prevent this from happening?


Need to show some code, but most likely you're not calling [myTextField resignFirstResponder] just before calling the UIPickerView.


You need to resign your keyboard for your textField. From the fact that you did not do it, I am guessing that you did not resign the pickerView as well. So you need to resign both of them or they will continue to stay on the screen

Resigning the textField.

  1. Implement UITextFieldDelegate
  2. Implement

    - (BOOL) textFieldShouldReturn:(UITextField *)textField
    {
    [textField resignFirstResponder];
    
    return 1;
    }
    

Resigning pickerview:

Implement the picker view as your property and implement [self.yourpickerview resignFirstResponder] in textFieldDidEndEditing and in the IBAction of your custom DONE button for your picker view.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜