2

目前我有以下代码viewDidLoad

if #available(iOS 9.0, *) {
    if traitCollection.forceTouchCapability == .Available {
        registerForPreviewingWithDelegate(self, sourceView: tableView)
    }
}

关键是,在这种情况下,模糊的是一切UITableView都来自于那个特定的东西,而不是一切UITableViewCell

我怎样才能只暴露一个细胞?

此图像在强制 3d 触摸期间的状态。 在此处输入图像描述

4

2 回答 2

0

这应该在viewDidLoad()

if traitCollection.forceTouchCapability == .available {
    registerForPreviewing(with: self, sourceView: tableView)
}

然后在previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint)添加这个:

guard let selectedIndexPath = tableView.indexPathForRow(at: location) else { return nil }
previewingContext.sourceRect = tableView.rectForRow(at: selectedIndexPath)
于 2020-03-17T21:16:51.573 回答
-1

您做得对,您确实需要在viewDidLoad . 虽然,您还需要实现该previewingContext方法,以提供源 rect。基本上,您会将单元格作为源矩形,并且它之外的所有内容都会变得模糊。

请查看此Peek and Pop 教程以获取更多详细信息。

您还可以签出代码示例

于 2016-01-03T21:49:04.910 回答