我遇到了与 UIScrollview 启用通过滑动删除行一个>
它是一个 tableView 和另一个视图作为 scrollView 的子视图工作,我无法启用滑动删除",直到我将 scrollView 的 scrollEnable 属性设置为 NO,但它带来了另一个问题:我无法在 tableView 和另一个视图之间滑动
除了设置 scrollEnable 属性以启用滑动删除"之外,还有其他方法吗?
如果不是,我应该什么时候设置 self.scrollEnable = NO
,什么时候应该设置 self.scrollEnable = YES
以具有滑动删除"和在视图之间滑动"两者都工作正常?
I've encountered a problem the same as UIScrollview enable delete row by swipe
It is a tableView and another view work as subViews of a scrollView , and I can't enable "swipe to delete" until I set the scrollEnable property of the scrollView to NO , but it brings another problem : I can't swipe between the tableView and another view
Is there any ways other than setting the scrollEnable property to enable "swipe to delete" ?
If not , when should I set self.scrollEnable = NO
, and when should I set self.scrollEnable = YES
to have the "swipe to delete" and "swipe between views" both work fine ?
谢谢
如果我没记错的话,滚动视图会消耗触摸并且表格的编辑不会发生,因为表格没有得到触摸.这可以通过继承 UIScrollView 来解决,以便将触摸也发送给下一个响应者.所以这只是覆盖touchesBegan、move 和end 的问题.今天晚些时候将使用我现在在路上所需的代码更新答案.干杯!
If , I'm not mistaken , the touches are consumed by the scrollview and the editing of the table is not happening because the table is not getting the touches. This can be resolved by subclassing the UIScrollView in order to snd the touches to the next responder too. So it's just a matter of overrwriting the touchesBegan, moved and ended. Will update the answer later today with the code needed as I am on the road now. Cheers!
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.nextResponder touchesBegan:touches withEvent:event];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
if(!self.dragging)
{
[self.nextResponder touchesMoved:touches withEvent:event];
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.nextResponder touchesEnded:touches withEvent:event];
}
只需创建一个继承自 UIScrollView
的类,然后在实现中删除此代码.这将使 scrollView 不会吞下触摸,而是将它们传递下去.显然,在创建你的滚动视图时使用你刚刚创建的类而不是 UIScrollView
.抱歉耽搁了.希望这会有所帮助.
Just create a class that inherits from UIScrollView
and in the implementation drop this code. This will make the scrollView to not swallow the touches, but pass them on. Obviously , when creating your scrollView use the class you just created instead of UIScrollView
.
Sorry for the delay. Hope this helps.
干杯!
这篇关于滑动删除嵌入在 UIScrollView 中的 UITableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!