Вопрос

I have an universal app where in the keyboard I put these controls. In the iPhone version (which is in portrait) everything works perfectly, while the iPad version (which is in landscape) are visible but not selectable. How can I do?

The code:

 NSArray *fields = [NSArray arrayWithObjects: self.textFiel1,
                       self.textField2,
                       self.textField3,
                       self.textField4,
                       self.textField5,
                       self.textField6,
                       nil ];

 [self setKeyboardControls:[[BSKeyboardControls alloc] initWithFields:fields]];
 [self.keyboardControls setDelegate:self];

 [self.textFiel1 becomeFirstResponder];


 #pragma mark Text Field Delegate

 - (void)textFieldDidBeginEditing:(UITextField *)textField
 {
     [self.scrollView scrollRectToVisible:textField.frame animated:YES];
     [self.keyboardControls setActiveField:textField];
 }

 - (void)keyboardControls:(BSKeyboardControls *)keyboardControls selectedField:
   (UIView *)field inDirection:(BSKeyboardControlsDirection)direction
 {

     UIView *view = keyboardControls.activeField.superview.superview;

     [self.scrollView scrollRectToVisible:view.frame animated:YES];
  }


 - (void)keyboardControlsDonePressed:(BSKeyboardControls *)keyboardControls
{
    [keyboardControls.activeField resignFirstResponder];
}

In the code I have not made a distinction between iphone and ipad thinking it was the same. for the construction of the controls I have followed this example: https://github.com/simonbs/BSKeyboardControls/tree/bdb2200829d5f2aa082b3eb93fda00de5abf14d5/Example/Example

Это было полезно?

Решение

You have to check if the UITextField in the xib is set the delegates. In this case you have set the delegates in iPhone UITextFiled, while the delegates of UITextFiled in iPad were not set, then the inputAccessoryView not see the text fields.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top