iphone - 不允许将单元格移动到另一个部分

标签 iphone uitableview

如何禁止用户将单元格移动到其他部分?我不想每次都显示警报;)​​

谢谢:D

最佳答案

实现 targetIndexPathForMoveFromRowAtIndexPath 委托(delegate)方法:

- (NSIndexPath *)tableView:(UITableView *)tableView 
    targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath 
    toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath
{
    if (proposedDestinationIndexPath.section != sourceIndexPath.section)
    {
        //keep cell where it was...
        return sourceIndexPath;
    }

    //ok to move cell to proposed path...
    return proposedDestinationIndexPath;
}

关于iphone - 不允许将单元格移动到另一个部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4949130/

相关文章:

ios - 原生 iPhone 上的 Swift UITableView 黑色背景

ios - 无法在 UISearchResultsTableView 中滚动到底部

ios - 添加行后如何更新 UITableView?

ios - 在 Xcode 类型 "ViewController"中获取错误不符合协议(protocol)“UITableViewDataSource”

json - 仅在 JSON 之后加载 tableView

iphone - 提交第一个 iOS 应用程序。我需要做什么?

iphone - 网站在 iPhone 和 iPad 上都太宽

iphone - 框架(RestKit)与armv7s不兼容

iphone - 在 UITableView 中显示元素,就像 iPhone 联系人一样,分成按字母顺序排列的部分?

iphone - UIScrollView subview 内容大小问题