开发者

UIScrollView not detecting touch event

I have a scroll view which has some controls like textField an开发者_如何学Cd textArea on it. I want to detect the touches event on scroll view so that I can use resignfirstresponder on my textfields.

I have also tried subclassing UIScrollview, but the approach didnt work for me. Can anyone please help me in detecting touches event on scrollview?

Please help. Thanks in advance


It works well for me to subclass UIScrollView and listen to touches like so:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];

    if([touch tapCount] == 1)
    {
        NSLog(@"One Touch!");
    }
}

If you are having problems, perhaps you have views inside the scroll view that block the touches? To test things out create a new View, add a scrollview that you subclass with the touchesBegan code above and at least you'll see that it works. Then add more elements from your original code to see where your problem really is.

Good luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜