0
votes

I have a strange problem where I have a scroll view on one of my views that works perfectly on 4-inch devices, both in simulator and actual device. That same scroll view (and views inside it) doesn't respond to any touch event (both tap and scroll) in 3.5-inch devices (same iOS version, 7.0.3). It renders/displays perfectly though. I've even tried to add a tap handler to the view itself directly to see if it will hit (categoriesScrollView is my view):

//viewDidLoad:
UITapGestureRecognizer *test = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(test)];
    [categoriesScrollView addGestureRecognizer:test];

-(void)test{
    NSLog(@"test");
}

It doesn't hit. Inside the view there are buttons, that can be tapped perfectly on an 4-inch device. This problem occurs both on device and simulator. The first thing that I checked was any device/screensize-specific code, but there isn't any. The second thing I've checked is the layout constraints: Maybe the scrollview's actual bounds was getting smaller (maybe even zero) on 3.5 inch device, but I've checked the frames and everything is normal (the scroll view has clipsToBounds set to YES anyway, so if this was the case, the content would be invisible anyway).

All the other views inside the same view other than this scroll view and its subviews are receiving touch/running perfectly normal. I can't think of anything else, what can be causing this?

1
This is really weird. I don't see how this could be related to the screen size, but is userInteractionEnabled set to YES in both cases? Furthermore, could it be that on the 3.5 inch "version" some transparent view (or a portion of it) gets above your scrollView and swallows the touch events?Andrea Sprega
yes, userInteractionEnabled is YES in every case (I don't touch it anyway and it's set to YES in IB, but still, checked it at runtime) I've also thought about another view overlapping and consuming the touches, but it's apparently not the case. there is another scroll view below that, and to check if that overlaps my problematic view, i've also added a gesture recognizer to output something else, and it does output correctly when I tap it, but doesn't output anything when I tap my the problematic view. if the other scroll view did overlap this view, it should have outputted in any case.Can Poyrazoğlu
Did you try setting a delegate for the scrollview, implement scrollViewWillBeginDragging: and see if it gets called? If not, you should try with a "fake" temporary subclass for your UIScrollView and implement the –touchesBegan:withEvent:, –touchesMoved:withEvent:, –touchesEnded:withEvent: methods (from UIResponder) to see if they get called. If you do create this subclass, don't forget to set the custom class name in Interface Builder. NOTE: I'd remove the test gesture recognizer as it may cancel the touch event once processed.Andrea Sprega
okay, got the problem. I've first put another button somewhere inside the main view on top of the scroll view (but scroll view was inside another container, top bar), the button worked. i've moved the button inside the same container with scroll view (on top of it), and it didn't work where alarm bells rang for me. apparently, i had an indicator and that indicator was centered in the main below with top constraint to the top bar. top bar had clipsToBounds set no NO and the indicator was pushing the size of the top bar to almost zero, making the scroll view draw but not respond to touch.Can Poyrazoğlu

1 Answers

2
votes

I've solved the problem. I've first put another button somewhere inside the main view on top of the scroll view (but scroll view was inside another container, top bar), the button worked. I've then moved the button inside the same container with scroll view (on top of it), and it didn't work where alarm bells rang for me. Apparently, I had a progress indicator and that indicator was centered in the main below with top constraint to the top bar. Top bar had clipsToBounds set no NO and the indicator was pushing the size of the top bar to almost zero, making the scroll view draw but not respond to touch. It was a simple autolayout issue, and the top bar which contains the scroll view didn't clip the scroll view out of it's bounds, which made the bug harder to find.