1

I've tried using the PageViewerViewController in order to pass through few pages in scrollMode. Like another question here in SO (I can't seem to find it tough) I want to capture the touch. so on viewDidLoad I searched through the Views in that controller and found the scrollView and just added a TapGestureRecognizer and it didn't work that well so I added self as its delegate and told him to work simultaneously with other GestureRecognizers and than it worked fine. The thing is, when I try to click on a UIButton on one of the pages, it doesn't recognize the click. and when I set the work simultaneously to off, it suddenly works fine. What am I doing wrong?
More Info: I think I went all over the web with the following problem, and tried to write the code from scratch, tried to change the code, and adding another TapGestureRecognizer so far has the best outcomes.

I'm currently out of any ideas. Any advice is appreciated. Thank you.

For more clarification, I'm trying to captrue all touchStarted, touchMoved, touchEnded on UIPageViewerViewController in ScrollMode. I tried adding another UITapGestureRecognizer to the inner UIScrollView, to the superview of UIScrollView, to self.view of which the UIPageViewerViewController is added on. and when I remove the working simultanously my UITapGestureRecognizer stops working randomly. When I set the working simultanously to work, I'm not able to click any UIButton until I start another UIViewController. and then for some reason, it does work.

Edit I'm only using 3 pages, is UIScrollView better?

I changed everything to just a UIScrollView, when I remove the UITapGesureRecognizer, everything works fine, I receive touches, and everything runs smoothly.

Is there any other way than UITapGestureRecognizer added to UIScrollView to capture touch?

2 Answers 2

1

Your button doesn't recognize clicks because the tapGestureRecognizer intercepts them. You can set more complicated area where tapGestureRecognizer has major priority. Try to add this code:

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
    if (gestureRecognizer == yourTapGestureRecognizer) {
        return !CGRectContainsPoint(yourButton.frame, [gestureRecognizer locationInView:yourScrollView]);
    }
    return YES;
}
Sign up to request clarification or add additional context in comments.

9 Comments

Hi, I tried implementing that function but for some reason gestureRecognizerShouldBegin isn't fired
What's the target of yout tapGestureRecognizer?
some function that never got called so I just left it empty. I did all the work on touchesBegin till touchesEnded when I subclassed that UITapGestureRecognizer
I asked about the target but not the selector. The target must me your class (basically UIViewController) where your selector is called.
I think you should update your question by adding the most significant parts of your code. Now I'm confused of what exactly you use :)
|
0

I think for what you are looking for a UIView would be better than a UIScrollView. If you want to get all the touch events anyway then you can just implement your own scrollview functionality. You can do the paging in onTouchEnded: by UIView animations setting the UIView's origin to some value based on where the touch ended. It's a bit of work, but it would likely be easier than trying to send touch events to two places when Apple wants to consume them in the ScrollView.

1 Comment

Subclassing UiScrollview and implementing the same functions won't work?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.