选择UITextField时如何显示UIPickerView [英] How to Show UIPickerView when selecting UITextField

查看:95
本文介绍了选择UITextField时如何显示UIPickerView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我到目前为止所做的屏幕截图:

Here is a screenshot of what I did till now:

所以我想做的是,当您选择选择名称"文本字段时,我需要一个选择器来显示,并输入@"Jack".

So what I am trying to do is when you select "pick a name" Textfield I need a Picker to show up, with the input @"Jack".

推荐答案

它将为您工作..我已经对其进行了编辑.为此,您必须为文本字段设置委托.并在NIb文件中创建UIPIckrView.

it will work for you .. i have edited it .and for that you have to set delegate for textfield. and create a UIPIckrView in NIb file.

- (BOOL) textFieldShouldBeginEditing:(UITextView *)textView
{
    pickrView.frame = CGRectMake(0, 500, pickrView.frame.size.width,    pickrView.frame.size.height);
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:.50];
    [UIView setAnimationDelegate:self];
    pickrView.frame = CGRectMake(0, 200, pickrView.frame.size.width, pickrView.frame.size.height);
    [self.view addSubview:pickrView];
    [UIView commitAnimations];
    return NO;
}

这篇关于选择UITextField时如何显示UIPickerView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆