iphone - 滑动删除具有奇怪行为的单元格

标签 iphone objective-c ios ipad

我有一个应用程序,其中主根是 UIViewController,其行为与 facebook 或 path 的应用程序类似,即滑动并在左侧或右侧显示另一个 View 。 enter image description here

但是,我的问题是,有时主 UIViewController 有 UITableViewcells,应该通过滑动来消除它,但这不能正常工作,有时它会检测到手势,有时则不会。

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{
return YES;

}

    - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {

    [dataItems removeObjectAtIndex:indexPath.row];
    [self.tableView reloadData];

}    

}

我正在采用这个库 enter link description here 制作 UIViewController 的 Controller

知道如何解决这个问题吗?

提前致谢。

最佳答案

问题在于您使用的手势。如果表格单元格和 View 都试图拦截滑动事件,那么您肯定不会得到您正在寻找的行为。我通常解决这个问题的方法是制作一个将表格更改为编辑模式的按钮。这样你们就不会发生冲突。

[tableView setEditing:YES animated:YES];

问题不在于程序设计或语言能力,而在于用完全相同的手势做两件不同的事情。这在物理上不可能实现并且总能得到你想要的。 iOS 设备无法读心,尽管我听说 iOS 7 中有一个新的 API...

您可以尝试使用多指手势。

关于iphone - 滑动删除具有奇怪行为的单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11762861/

相关文章:

ios - 没有模糊 View 效果的 UIAlertController 操作表

IOS App登录后切换 View

ios - 在 ios 4.3 + iphone sdk 的 textview 中自动滚动

iphone - 即使重新加载表格后文本的颜色也不会改变

iphone - iphone赛车游戏在cocos3d中

objective-c - iPad应用程序奇怪的崩溃

iOS 11 自定义 UIAlertView 渲染不正常

ios - 扩展 UINavigationBar 高度

iphone - 基础 SDK 3.0 到 SDK 4.0

iphone - UIScrollView覆盖UIButton