- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
在我的测试演示中,我将 UITableView 放入 Storyboard 中的 UIViewController 中。当我在我的 iPhone 上测试演示时,我在 tableView 中按下一个单元格,我在图片中出现了这个错误
在 func previewingContext(previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController?
方法中,我使用
guard let indexPath = tableView.indexPathForRowAtPoint(location), cell = tableView.cellForRowAtIndexPath(indexPath) else { return nil }
获取 UITableView 中按下的单元格。
如果您能给我任何答案,我将不胜感激!
最佳答案
当你注册你的源 View 时,你是在添加 View Controller 的 View 还是你的 TableView ?我在 Collection View 上遇到了类似的问题,但是一旦我注册了实际 View 而不是 View Controller 的 View ,行为就得到了纠正。
换句话说..
这给了我错误的单元格
registerForPreviewingWithDelegate(self, sourceView:self.view)
这纠正了行为
registerForPreviewingWithDelegate(self, sourceView:self.tableView)
关于ios - 我用3D touch在UITableViewl中按下了一个cell,然后提示错误的cell view,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33194364/
我是一名优秀的程序员,十分优秀!