首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >显示UIPicker和键盘

问显示UIPicker和键盘
EN

Stack Overflow用户
提问于 2013-11-20 22:48:26
回答 1查看 159关注 0票数 0

我的需求要求我在显示keyboard的同时显示一个数值型UIPickerView。当我在文本字段中单击时,我创建的数字选择器不会立即出现,尽管键盘会出现。当我单击表中的行时,文本字段中没有光标,但出现了选择器。

当用户单击textfield时,应该显示选取器,并且还应该显示keyboard。两者同时存在。有三个原型行:数据行、日期选取器行和数字选取器行。数字选择器还需要允许从软件keyboard输入文本。

hideExistingPickerBelowIndexPath只是添加了一个选取器类型的新行,并向数据中添加了一个临时行。

代码语言:javascript
复制
-(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];
}

我们需要用软件键盘在文本字段中显示选取器和光标。这两者同时存在。我该怎么做?

EN

回答 1

Stack Overflow用户

发布于 2013-11-20 23:42:10

所以你所描述的是一系列的需求。项目here演示了您可以拥有一个活动的选取器和一个显示键盘的活动的textField。所以你想要的核心功能是由系统提供的。

在显示键盘时,应该可以在视图中设置选择器的动画,如演示项目所示,您可以在textField中点击文本并旋转选择器。

在尝试将其集成到一个复杂的项目之前,启动一个非常简单的演示项目来测试一些东西,以确保它是正确的,这通常真的很有帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20099056

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档