- 解决成员变量block循环
__weak typeof(self) weakSelf = self;
__strong typeof(weakSelf) strongSelf = weakSelf;
用strongSelf修饰的self 必须为 __weak 修饰过以后的self
strongSelf->解决成员变量,block循环引用
- 重写hittest
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
for (UIView *subview in [self.subviews reverseObjectEnumerator]) {
CGPoint convertedPoint = [subview convertPoint:point fromView:self];
UIView *hitTestView = [subview hitTest:convertedPoint withEvent:event];
if (hitTestView) {
return hitTestView;
}
}
return [super hitTest:point withEvent:event];
}
- 移除某个view的手势加在另一个上
//移除scrollViewA原有手势操作
NSMutableArray *list = [NSMutableArray arrayWithArray:scrollViewA.gestureRecognizers];
for (UIGestureRecognizer *gestureRecognizer in list) {
[scrollViewA removeGestureRecognizer:gestureRecognizer];
}
//将scrollViewB的手势操作加到scrollViewA中
for (UIGestureRecognizer *gestureRecognizer in scrollViewB.gestureRecognizers) {
[scrollViewA addGestureRecognizer:gestureRecognizer];
}
网友评论