How does a UIViewController inside a UIPageController receive touch events?

It seems that the button is simply not pressed.

I tried:

UIPageViewController gesture recognizers

However here is catch

if the UIPageViewController page transition is UIPageViewControllerTransitionStyleScroll, then

self.view.gestureRecognizers = self.pageViewController.gestureRecognizers; NSLog(@"%@",self.pageViewController.gestureRecognizers.description); NSLog(@"%@",self.pageViewController.gestureRecognizers.description); 

will be just empty.

I tried adding my own gecureRecoqnizers instead of a button in the subview of the UIViewControllers. This still does not work.

So, I have a UIPageViewController that displays a UIViewController whose view has some button. How do I click this button?

I also tried both solutions here:

http://emlyn.net/posts/stopping-gesture-recognizers-in-their-tracks

Nothing works. First of all, I can’t disable the UIPageViewController gesture recognizers because there isn’t such a thing. In scrollView mode, the UIPageViewController does not have gesture reminders.

I tried adding my own gesture guides to my own button, but they are never called.

I want the UIPageViewController to still process napkins. But do not click.

I cannot access the gestures recipeers of UIPageViewControllers because self.pageViewController.gestureRecognizers is empty. The UIPageViewController seems to simply "absorb" all the crane events. So my button does not receive it.

I can add a button in front of the UIPageViewController, but this button will absorb the swiping action that I want the UIPageVIewController to still handle.

By the way, if we use a template from iOS (we create a page-based application and change the transition to page scrolling viewcontroller.gesturerecoqnizers will be empty

 - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. // Configure the page view controller and add it as a child view controller. self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];//Turn this to scroll view self.pageViewController.delegate = self; SDDataViewController *startingViewController = [self.modelController viewControllerAtIndex:0 storyboard:self.storyboard]; NSArray *viewControllers = @[startingViewController]; [self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:NULL]; self.pageViewController.dataSource = self.modelController; [self addChildViewController:self.pageViewController]; [self.view addSubview:self.pageViewController.view]; // Set the page view controller bounds using an inset rect so that self view is visible around the edges of the pages. CGRect pageViewRect = self.view.bounds; if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { pageViewRect = CGRectInset(pageViewRect, 40.0, 40.0); } self.pageViewController.view.frame = pageViewRect; [self.pageViewController didMoveToParentViewController:self]; // Add the page view controller gesture recognizers to the book view controller view so that the gestures are started more easily. self.view.gestureRecognizers = self.pageViewController.gestureRecognizers; NSLog(@"%@",self.pageViewController.gestureRecognizers.description); //This is empty while (false); } 
+6
source share
1 answer

Perhaps you can configure a custom gesture recognizer in your UIPageViewController. That way, you can filter through UITouch events by implementing this in your gesture recognizer deed (the one used for your UIPageViewController):

 - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gesture shouldReceiveTouch:(UITouch *)touch { if (touch.tapCount > 1) { // It will ignore touch with less than two finger return YES; } return NO; } 

This, you will report that UCRageViewController gestureRecognizer does not care about touching with one finger. You will have to try, but I think this can do the trick. The problem here is that you have to ask your user to hold two fingers ...

Check here for another answer.

0
source

Source: https://habr.com/ru/post/950783/


All Articles