gpt4 book ai didi

ios - 我用3D touch在UITableViewl中按下了一个cell,然后提示错误的cell view

转载 作者:可可西里 更新时间:2023-11-01 06:19:07 24 4
gpt4 key购买 nike

在我的测试演示中,我将 UITableView 放入 Storyboard 中的 UIViewController 中。当我在我的 iPhone 上测试演示时,我在 tableView 中按下一个单元格,我在图片中出现了这个错误

wrong cell view

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com