http://www.cocoachina.com/ios/20150604/12013.html
方案一:
+ (BOOL)resolveInstanceMethod:(SEL)sel
+ (BOOL)resolveClassMethod:(SEL)sel (类方法)
方案二:
- (id)forwardingTargetForSelector:(SEL)aSelector
方案三:
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector;
- (void)forwardInvocation:(NSInvocation *)anInvocation;
到目前为止大家已经知道什么是消息转发了。下面就说一下这几套方案是怎样调用的。
首先,系统会调用resolveInstanceMethod(当然,如果这个方法是一个类方法,就会调用resolveClassMethod)让你自己为这个方法增加实现。
----------------------------------------View不响应事件----------------------------------------------
重写父级view 的hitTest 事件让自己不响应事件
- (id)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
id hitView = [super hitTest:point withEvent:event];
if (hitView == self) return nil;
else return hitView;
}
时间: 2024-10-06 00:53:47