UIPickerView作为UITextField的inputView [英] UIPickerView as inputView of UITextField

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

问题描述

我已经阅读了很多关于如何使用 UIPickerView 作为我的<$ c的 inputView $ C>的UITextField 。问题是,当我点击 UITextField 时,我可以调用 UIPickerView 。但是,我的应用程序始终加载显示的 UIPickerView 。我已经尝试在 viewDidLoad 中更改 myownpickerview.hidden = YES; ,但是当我点击的UITextField 。它不会显示,如果我多次单击,调试器会显示错误。

I've read a lot about how I can use a UIPickerView as the inputView of my UITextField. The thing is, I am able to call the UIPickerView when I tap on the UITextField. However, my app always loads with the UIPickerView shown. I have already tried changing the myownpickerview.hidden = YES; in viewDidLoad, but this causes problems when I click on the UITextField. It won't show up, and if I click multiple times, the debugger shows that there would be an error.

有人能指出我正确的方向吗?我只想在点击 UITextField

Can anyone point me in the right direction? I only want the UIPickerView shown after I tap on the UITextField

我还在开发我的第一款iOS应用程序。请耐心等待。谢谢=)

I'm still working on my first ever iOS app. Please be patient. Thank you =)

推荐答案

试试这个,它运行正常,把它放在viewdidload中。

Try this, it works fine, put it in viewdidload.

yourpicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 50, 100, 150)];
    [yourpicker setDataSource: self];
    [yourpicker setDelegate: self];
    yourpicker.showsSelectionIndicator = YES;
    self.yourtextfield.inputView = yourpicker;

[self.view addSubview: yourpicker]; 这个

这篇关于UIPickerView作为UITextField的inputView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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