Double click inside another UIScrollView

I want to teach this question by the fact that I am new to iphone application development and many times believe that I can be above my head. I am trying to find an action that will allow me to double-click anywhere in my full-screen UIScrollView to return to the main menu (MainMenuViewController).

Currently, the following code works for my ScrollViewController:

ScrollViewController.h #import <UIKit/UIKit.h> @interface ScrollViewController : UIViewController <UIScrollViewDelegate> { } @end ScrollViewController.m #import "ScrollViewController.h" UIScrollView *myScrollView; UIPageControl *myPageControl; @implementation ScrollViewController - (void)loadScrollViewWithPage:(UIView *)page { int pageCount = [[myScrollView subviews] count]; CGRect bounds = myScrollView.bounds; bounds.origin.x = bounds.size.width * pageCount; bounds.origin.y = 0; page.frame = bounds; [myScrollView addSubview:page]; } ...etc 

Any advice or sample code for implementing double-clicking in a ScrollView controller is welcome so that I can return to my MainMenuViewController. In addition, please include changes to the Builder interface in the view (if necessary). I poured on the forums for many days and could not successfully complete this action. Thanks ... RJ

+4
source share
1 answer

First of all, create a subclass of UIScrollView:

 #import <UIKit/UIKit.h> @interface MyScrollView : UIScrollView { } @end 

Deploy it:

 #import "MyScrollView.h" @implementation MyScrollView - (void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event { if (!self.dragging) { [self.nextResponder touchesEnded: touches withEvent:event]; } [super touchesEnded: touches withEvent: event]; } - (void)dealloc { [super dealloc]; } @end 

Then use this subclass instead of the usual UIScrollView in the main view controller. This will call the touchesEnded: withEvent: method (alternatively, you can call any method you want). Then follow the double labels (if you need information on how to do this, let me know).

+1
source

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


All Articles