偷看和流行继续显示下一个

时间:2019-03-05 21:32:42

标签: ios swift 3dtouch peek-pop

我有这个范围

extension DevicesViewController : UIViewControllerPreviewingDelegate {

    func detailViewController(for indexPath: IndexPath) -> DeviceDetailViewController {
        guard let vc = storyboard?.instantiateViewController(withIdentifier: "DeviceDetailViewController") as? DeviceDetailViewController else {
            fatalError("Couldn't load detail view controller")
        }

        let cell = deviceTableView.cellForRow(at: indexPath) as! DeviceTableViewCell

        vc.title   = cell.deviceName?.text
        vc.device = loginAccount.cpeDevices[indexPath.row]

        return vc
    }

    func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
        if let indexPath = deviceTableView.indexPathForRow(at: location) {

            // Enable blurring of other UI elements, and a zoom in animation while peeking.
            previewingContext.sourceRect = deviceTableView.rectForRow(at: indexPath)

            return detailViewController(for: indexPath)
        }
        return nil
    }

    //ViewControllerToCommit
    func previewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController) {

        // Push the configured view controller onto the navigation stack.
        navigationController?.pushViewController(viewControllerToCommit, animated: true)
    }

}

在我的viewDidLoad()

override func viewDidLoad() {
    super.viewDidLoad()

    if (self.traitCollection.forceTouchCapability == .available){
        //print("-------->", "Force Touch is Available")
        registerForPreviewing(with: self, sourceView: self.deviceTableView)
    }
    else{
        //print("-------->", "Force Touch is NOT Available")
    }

    ....

我不知道为什么它继续显示列表中的下一个。

如何进一步调试呢?

0 个答案:

没有答案