UIControl和UIView的事件传递有关问题

UIControl和UIView的事件传递问题对于UIControl子类中的- (-(传递中子类监听touchbegin,传递回来给UIContr

UIControl和UIView的事件传递问题

对于UIControl子类中的

- (-(

传递中子类监听touchbegin,传递回来给UIControl子类,UIControl子类只能监听对于的touchesBegan,而没有触发beginTracking.


解决方案:

在UIControl子类调用

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{    NSLog(@"my control touch begin");    [super touchesBegan:toucheswithEvent:event];    UITouch* touch = [touches anyObject];    // Track the touch    [self beginTrackingWithTouch:touch withEvent:event];}- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event{    [super touchesMoved:toucheswithEvent:event];    // Get the only touch (multipleTouchEnabled is NO)    UITouch* touch = [touches anyObject];    // Track the touch    [self continueTrackingWithTouch:touch withEvent:event];}....end