OGeek|极客世界-中国程序员成长平台

标题: iphone - PkRevealController 和 canEditRowAtIndexPath [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 00:41
标题: iphone - PkRevealController 和 canEditRowAtIndexPath

我使用 PKRevealController 作为滑动条菜单,在我的前端 Controller 中我有一个带有 canEditRowAtIndexPath 的表格 View ,因为我实现了 PKRevealController 滑动每个单元格时出现的删除按钮停止显示,我怎样才能让它再次工作?



Best Answer-推荐答案


截至撰写本文时,还没有已知的方法(至少对我而言)可以在我的 Controller 端解决此问题,以便在所有可以想象的条件下正常工作。 IE。您需要自己处理上述案件。因此, Controller 向您公开 revealPanGestureRecognizer 属性。

简单地说,当实例化 Controller 时,在你的选项字典中传递这个选项:

NSDictionary *options = @{
    PKRevealControllerRecognizesPanningOnFrontViewKey : @NO
};

这将禁用整个前 View 的基于平移的显示。现在,您可以使用revealPanGestureRecognizer 并将其添加到您希望平移的任何 View 中,以启用基于手势的显示。

我建议(如果使用带有可编辑单元格的基于表格的环境)您将 revealPanGestureRecognizer 添加到前 View Controller 的导航栏(它很可能有):

[self.navigationController.navigationBar addGestureRecognizer:self.revealController.revealPanGestureRecognizer];

瞧,平移不再干扰您的表格 View 。

(有关这方面的更多信息以及一些基本原理,请参阅 https://github.com/pkluz/PKRevealController/pull/76)

--

注意:还有另一种方法可以使用 UIGestureRecognizerDelegate 协议(protocol)方法来处理这个问题:

- (BOOL)gestureRecognizerUIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizerUIGestureRecognizer *)otherGestureRecognizer

虽然看到 UITableView 有大约五个手势识别器并且它在全局范围内处理单元格的编辑模式可能会有点困惑......

关于iphone - PkRevealController 和 canEditRowAtIndexPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14590616/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4