我将 SWRevealViewController 添加到我的应用程序中,并添加了汉堡包堆栈来访问我的菜单。我的应用程序有一个 UITableView 作为主应用程序视图。我想允许用户使用滑动删除功能从列表中删除项目。
我启用了滑动删除功能,并添加了一个方法调用来处理此问题。我注意到该方法永远不会被调用。不知道如何让它发挥作用。
任何帮助将不胜感激。
有人要求我提供代码示例。我没有对 SWRevealViewController 标准源代码进行任何更改。在 TableView 的代码中,我添加了以下内容:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
通常,当您从右向左滑动时,上面的代码应该显示一个删除按钮。然而,这并没有发生。我的猜测是 SWRevealViewController 正在吃掉平移手势识别器。
在阅读了一个向此类的创建者提出类似问题的人的帖子后,刚刚找到了解决方案。无论您使用什么类来添加手势识别器,请将其设为 SWRevealController 的委托,然后粘贴到此方法中。
#pragma mark - SWRevealViewControllerDelegate
- (BOOL)revealControllerPanGestureShouldBegin:(SWRevealViewController *)revealController
{
float velocity = [revealController.panGestureRecognizer velocityInView:self.view].x;
if (velocity < 0 && self.revealViewController.frontViewPosition == FrontViewPositionLeft)
return NO;
else
return YES;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)