- (void)remoteControlReceivedWithEvent:(UIEvent *)event NS_AVAILABLE_IOS(4_0); ```
- *这些方法在响应事件时需要自己重写方法。*
##UIView中的触摸事件 - 自定义view,实现几个方法,如果要响应UIView的触摸事件,需要自定控件的CustomClass为自定义的类,然后再自定义的类中实现以下方法。 ```objc
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"%s",__func__); NSLog(@"%@",touches); NSLog(@"----%@",event); }
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"%s",__func__); UITouch *touch = [touches anyObject]; CGPoint location = [touch locationInView:self]; CGPoint previous = [touch previousLocationInView:self]; CGFloat offsetX = location.x - previous.x; CGFloat offsetY = location.y - previous.y; self.transform = CGAffineTransformTranslate(self.transform, offsetX, offsetY); }
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"%s",__func__); }
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"%s",__func__); }
|