views:

34

answers:

1

Hi All,

I have a scroll view which has some controls like textField and 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

+2  A: 

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!

Merrimack