Map*_*ple 8 ios inputview ios8
我有一个UITextField使用自定义UIPickerView其inputView用户限制在几个选项,功能类似于一个下拉列表.当与通过蓝牙连接的硬件键盘一起使用时,硬件键盘会覆盖(并隐藏)我的inputView.inputAccessoryView然而,相关的遗骸.按下我的硬件键盘上的"键盘"按钮(通常会显示默认的屏幕键盘为香草UITextField),一切都按预期工作.(我的意思是我inputView再次可见.)在iOS的早期版本(即7及以下版本)中,inputView调用时始终可见.
我已经暂时通过设置解决了这个问题UITextField的UIKeyboardType,从UIKeyboardTypeDefault到UIKeyboardTypeTwitter,但在硬件键盘不被识别为默认为该特定这只会工作UIKeyboardType.代码是pickerTextField.keyboardType = UIKeyboardTypeTwitter;(参见下面代码的大约2/3.)经过进一步测试,这个部分解决方案并不像看起来那么有用.
如何inputView在使用硬件键盘时正确显示我的所有情况?
相关代码段:
-(int)setUpPickerWheelAtXLoc:(int)xLoc andYLoc:(int)yLoc {
int qwidth = width - (xLoc - FORMBORDERLEFT);
// Set up inputView (pickerView) to replace the keyboard
self.pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(xLoc, yLoc, qwidth, height)];
self.pickerView.delegate = self;
self.pickerView.dataSource = self;
self.pickerTextField = [[UITextField alloc] initWithFrame:CGRectMake(xLoc, yLoc, qwidth, 32)];
self.pickerTextField.delegate = self;
pickerTextField.borderStyle = UITextBorderStyleRoundedRect;
pickerTextField.layer.borderWidth = 0.3f;
pickerTextField.layer.borderColor = [[UIColor blackColor] CGColor];
pickerTextField.textColor = [UIColor blackColor];
pickerTextField.font = [UIFont systemFontOfSize:XXLARGEFONTSIZE];
pickerTextField.placeholder = @"Tap to choose from list...";
// Add pickerView as inputView
pickerTextField.inputView = self.pickerView;
pickerTextField.keyboardType = UIKeyboardTypeTwitter; // Suggested temporary solution
// Setup inputAccessoryView (Done button)
UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[doneButton addTarget:self action:@selector(pickerDoneButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[doneButton setTitle:@"Done" forState:UIControlStateNormal];
doneButton.titleLabel.font = [UIFont systemFontOfSize:XXLARGEFONTSIZE];
doneButton.frame = CGRectMake(0,0,100,44);
[doneButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
doneButton.contentEdgeInsets = UIEdgeInsetsMake(0,0,0,20);
doneButton.backgroundColor = [UIColor lightGrayColor];
pickerTextField.inputAccessoryView = doneButton;
return xLoc + qwidth;
}
Run Code Online (Sandbox Code Playgroud)
附加信息:在检查了其他几个地方之后,我已经确认这种情况也发生在至少一个Apple产品中.(在8.0.2中的iPhone 6上的"创建新的Apple ID"应用程序/页面中.查看月和日的出生日期选择浏览量.)
| 归档时间: |
|
| 查看次数: |
676 次 |
| 最近记录: |