Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top