【发布时间】:2013-12-04 15:06:33
【问题描述】:
我的要求要求我在显示keyboard 的同时显示一个数字UIPickerView。当我单击文本字段时,我创建的数字选择器现在不会出现,尽管键盘会出现。当我点击表格中的行时,文本字段中没有光标,但出现了选择器。
当用户单击textfield 时,应显示选择器,同时应显示keyboard。两者同时。有三个原型行:一个数据行、一个日期选择器行和一个数字选择器行。数字选择器还需要允许从软件keyboard 输入文本。
hideExistingPickerBelowIndexPath 只是添加一个选择器类型的新行,并在数据中添加一个临时行。
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
{
if (indexPath != nil)
{
WCHistoryItem *anItem = [self getAnItemFromIndexPath:indexPath];
if ([anItem.type isEqualToString:kDate] || [anItem.type isEqualToString:kNumeric]) {
if (_isPickerVisible != NO)
{
[self hideExistingPickerBelowIndexPath:[NSIndexPath indexPathForRow:self.pickerIndexPath.row-1 inSection:self.pickerIndexPath.section]];
}
[self showNewPickerAtIndex:indexPath];
} else {
if (_isPickerVisible == YES) {
[self hideExistingPickerBelowIndexPath:[NSIndexPath indexPathForRow:self.pickerIndexPath.row-1 inSection:self.pickerIndexPath.section]];
}
}
}
}
-(IBAction)didBeginEditingNumericField:(UITextField*)sender
{
WCHistoryItem *anItem = [self getAnItemFromUIView:sender];
NSIndexPath *indexPath = [self getAnIndexPathFromUIView:sender];
if (_isPickerVisible == NO)
{
//make a date cell
[self showNewPickerAtIndex:indexPath];
} else {
[self hideExistingPickerBelowIndexPath:[NSIndexPath indexPathForRow:self.pickerIndexPath.row-1 inSection:self.pickerIndexPath.section]];
[self showNewPickerAtIndex:indexPath];
}
UITextField *textField = (UITextField*)sender;
[textField becomeFirstResponder];
}
我们需要使用软键盘在文本字段中同时显示选择器和光标。两者同时进行。我该怎么做?
【问题讨论】:
标签: ios objective-c ios7 keyboard uipickerview