UISlider只能滑动一小段距离 [英] UISlider only slide a small distance

查看:92
本文介绍了UISlider只能滑动一小段距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我使用以下代码将UISlider置于视图中,但一次只能滑动约10个点。它只能在大约20点的范围内来回拖动。为什么?

So I've put a UISlider into a view with the following code, but it could only be slided for the distance of about 10 points a time. It can only be dragged back and forth within a range of about 20 points. Why?

v = [[UIView alloc] initWithFrame:someFrame];
UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(10, 10, 200, 30)];
[v addSubview:slider];
[self.view addSubview:v];

我已将此代码放入另一个测试项目中,它确实起作用。因此,可能是其他一些代码。我想知道以前是否有人遇到过相同的问题。

I've put this code into another test project, it does work. So it might be some other code. I'm wondering if anyone else has been through the same problem before.

推荐答案

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
    if([[touch view] isKindOfClass:[UISlider class]])
    {
        return NO;
    }
}

我正在使用 IIViewDeckController ,因此我将这段代码添加到 IIViewDeckController.m 代码中,它解决了该问题!

I was using IIViewDeckController, so I added this piece into the IIViewDeckController.m code and it solved the problem!

这篇关于UISlider只能滑动一小段距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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