UITreviewInteraction在UITableViewCell上

时间:2018-05-10 13:33:07

标签: ios swift uitableview 3dtouch

我想在我的1添加一个UIPreviewInteraction,这样我就可以重新创建类似Apple Music的3D Touch动作。以下是我在UITableViewCell UITableView's

中所做的事情
cellForRowAt

然后我调用委托函数

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell")
        let interactionView = cell?.viewWithTag(1) as! UIView

        if #available(iOS 10.0, *) {
            var planPreviewInteraction = UIPreviewInteraction(view: interactionView)
            previewInteraction.delegate = self
        }

        return cell!

    }

但是从不调用委托方法。 func previewInteraction(_ previewInteraction: UIPreviewInteraction, didUpdatePreviewTransition transitionProgress: CGFloat, ended: Bool) { let buttonPosition = previewInteraction.view?.convert(CGPoint.zero, to: self.tableView) let indexPath = self.tableView.indexPathForRow(at: buttonPosition!) animator.fractionComplete = transitionProgress } func previewInteractionDidCancel(_ previewInteraction: UIPreviewInteraction) { } 似乎没有检测到UITableViewCell。有人可以帮我弄这个吗?

0 个答案:

没有答案
相关问题