允许用户通过点击来选择UIPickerView行 [英] Allowing user to select a UIPickerView row by tapping

查看:59
本文介绍了允许用户通过点击来选择UIPickerView行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将UIPicker View的行为与iPhone代码示例中常见的行为有所不同.

I'm trying to use a UIPicker View with a behavior somehow different of what's usually seen in iPhone code examples.

我想做的是允许用户滚动选择器的内容,而不是自动选择一个选择器的行(使用选择器委托中的"didSelectRow"方法).相反,我想允许用户触摸选择器的中心行,该行会突出显示并成为选择.

What I want to do is to allow users to scroll through the picker contents, but not to select a picker's row automatically (using the "didSelectRow" method from picker's delegate). Instead, I want to allow the user to touch the center row of the picker, which gets highlighted, and becomes the selection.

有什么办法可以做到这一点?

Is there any way to achieve this?

谢谢.

推荐答案

向UIPickerView添加一个手势识别器,该手势识别器将触发对象中的目标方法:

Add a gesture recogniser to the UIPickerView which triggers a target method in your object:

myGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pickerTapped:)];
[myPicker addGestureRecognizer:myGR];

// target method

-(void)pickerTapped:(id)sender
{
// your code
}

这篇关于允许用户通过点击来选择UIPickerView行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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