这是是主线程只能同时响应一件事件的原因,你按着button是一个事件了,再拖拽又是一个事件,所以,可以通过以下方法来解决
1.设置属性scrolls.panGestureRecognizer.delaysTouchesBegan = YES;
2.自定义Button
-(id)initWithFrame:(CGRect)frame
with:(UIScrollView *)scrollview
{
self = [super initWithFrame:frame];
if (self)
{
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(pan)];
[pan setDelegate:self];
[self addGestureRecognizer:pan];
[pan requireGestureRecognizerToFail:scrollview.panGestureRecognizer];
}
return self;
}
-(void)pan
{
NSLog(@"asds");
}
本文介绍了解决iOS应用中按钮点击与UIScrollView拖拽操作冲突的方法,通过调整UI控件的手势识别器延迟和自定义按钮实现两者操作的同时响应。
5293

被折叠的 条评论
为什么被折叠?



