Mik*_*e M 34 uibutton uiscrollview ios ios8
我有一个带有一行按钮的水平滚动视图.滚动视图不会滚动,除非我进行非常快速的滑动.
如果我将按钮设置为userInteractionEnabled = NO,则滚动按预期工作,但当然按钮根本不起作用.
此应用程序在iOS 7及之前运行良好.它似乎是一个iOS 8"功能".我注意到我可以捕获按钮的拖动事件,但我不知道如何将其重定向回scrollView.
我想我需要用UIViews替换我的按钮并自己管理这些事件,但如果有人有其他想法或解决方案,我将不胜感激.
lif*_*joy 39
我发现在iOS 8中,UIScrollView的底层UIPanGestureRecognizer不尊重UIScrollView的delaysContentTouches属性.我认为这是iOS 8的错误.这是我的解决方法:
theScrollView.panGestureRecognizer.delaysTouchesBegan = theScrollView.delaysContentTouches
Run Code Online (Sandbox Code Playgroud)
Dan*_*son 24
我有一个UITableView的问题,它有自定义UITableViewCells和UIButtons.我把它放在我的UITableview类中.
- (BOOL)touchesShouldCancelInContentView:(UIView *)view {
return YES;
}
Run Code Online (Sandbox Code Playgroud)
解决了我的问题.
编辑:只是为了清除,您可以创建UIScrollview的子类并添加它来解决问题.
dai*_*dai 10
这个黑客对我有用:
UITapGestureRecognizer *nothingTap = [[UITapGestureRecognizer alloc] init];
nothingTap.delaysTouchesBegan = YES;
[_scrollView addGestureRecognizer:nothingTap];
Run Code Online (Sandbox Code Playgroud)
信用:https://devforums.apple.com/thread/241467
我做了一个子类UIScrollView来解决这个问题.你只需要这个方法:
- (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view
{
UITouch *touch = [touches anyObject];
if(touch.phase == UITouchPhaseMoved)
{
return NO;
}
else
{
return [super touchesShouldBegin:touches withEvent:event inContentView:view];
}
}
Run Code Online (Sandbox Code Playgroud)
然后记得在故事板中将类设置为子类,如果你正在使用它,那么你很高兴.
| 归档时间: |
|
| 查看次数: |
10343 次 |
| 最近记录: |