UISlider only slide a small distance

2019-09-07 21:22发布

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.

1条回答
你好瞎i
2楼-- · 2019-09-07 21:45
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
    if([[touch view] isKindOfClass:[UISlider class]])
    {
        return NO;
    }
}

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

查看更多
登录 后发表回答