MyScrollView does not respond to touch when I send a touch event to view

I have a ViewController with a SubViewView ScrollView, and this subview has a subview in it, below is a hierarchy:

AppDelegate - MyViewController - ScrollView (from xib) - MyScrollViewSubClass

// MyViewController: //.h

@interface MyViewController : UIViewController<MyScrollViewSubClassDelegate,UIScrollViewDelegate> {
    UIScrollView            *scrollView; // Loaded from xib 
}

@property(nonatomic,retain) IBOutlet UIScrollView *scrollView;

@end

//.m

@implementation MyViewController

@synthesize scrollView;

- (void)viewDidLoad {
    [super viewDidLoad];

    scrollView.delegate = self;

    MyScrollViewSubClass *myScrollView = [[MapScrollView alloc] init];
    myScrollView.delegate = self;
    myScrollView.myDelegate = self;

    scrollView addSubview:mapScrollView];
}

// The MyScrollViewSubClassDelegate @required method

- (void) onDoubleTapLocation: (CGPoint)tapPoint
{
    // Working,,,NSLog shown that this line is Working... 
}

// MyScrollViewSubClass + Delegate //.h

// Protocol
@protocol MyScrollViewSubClasswDelegate <NSObject>
@required
- (void) onDoubleTapLocation: (CGPoint)tapPoint;
@end

//Interface

@protocol MyScrollViewSubClass;

@interface MyScrollViewSubClass : UIScrollView <UIScrollViewDelegate> {
    id <MyScrollViewSubClasswDelegate> myDelegate;

    // Another vars..   
}

@property (nonatomic,assign) id<MyScrollViewSubClasswDelegate> myDelegate;

- (void)handleDoubleTap;

@end

//.m

@implementation MyScrollViewSubClass
@synthesize myDelegate;

- (id)initWithFrame:(CGRect)frame
{
    if ((self = [super initWithFrame:frame])) {

        // Another Code Here...

        self.delegate = self; // delegate for UIScrollView
        self.myDelegate = self;

        //Another Code Here...

    }
    return self;
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
   if(isDoubleTap)
   {
      //Call handle double tap
      [self handleDoubleTap];
   }
}

- (void)handleDoubleTap {
    [self.myDelegate onDoubleTapLocation: tapLocation];
}

What happened with double-clicking works on MyViewController, but now I can’t scroll and pinch the scale of my MyScrollViewSubClass from MyViewController, any critics, comments or the best method are welcome.

It is decided:

I assign a delegate to MyViewController twice

:

myScrollView.delegate = self;
myScrollView.myDelegate = self;

Must be:

myScrollView.myDelegate = self;

Yours faithfully,

Ferry Hattavidian

+3
source share
1

:

MyViewController

:

myScrollView.delegate = self; 
myScrollView.myDelegate = self; 

:

myScrollView.myDelegate = self; 

... , ...

0

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


All Articles