我有一个通用的应用程序,在键盘中我放了这些控件。在iPhone版本(纵向)中,一切都很完美,而iPad版本(横向)是可见的但不可选择。我该怎么办?
代码:
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];
}
在代码中,我没有区分iphone和ipad,认为它是一样的。 为了构建控件,我遵循了这个例子: https://github.com/simonbs/BSKeyboardControls/tree/bdb2200829d5f2aa082b3eb93fda00de5abf14d5/Example/Example
答案 0 :(得分:0)
您必须检查xib中的UITextField是否设置了委托。在这种情况下,你已经在iPhone UITextFiled中设置了委托,而未设置iPad中UITextFiled的委托,则inputAccessoryView看不到文本字段。