Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/114.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 3DTouch上的SFSafariViewController出现问题(Pop状态)_Ios_Swift - Fatal编程技术网

Ios 3DTouch上的SFSafariViewController出现问题(Pop状态)

Ios 3DTouch上的SFSafariViewController出现问题(Pop状态),ios,swift,Ios,Swift,我正在尝试在TableViewController中实现Peek和Pop功能,这样当我3次触摸任何单元格时,它会向我显示SFSafariViewController的预览,他们会带我去点击它们。peek功能工作正常,但一旦移动到弹出状态,它不会在中显示SFSafariViewController,而是从上一个视图显示导航控制器,并且显示SFViewController的视图尺寸很小 这就是我如何在我的TableViewController中编程peek和pop功能的方法: extension M

我正在尝试在
TableViewController
中实现Peek和Pop功能,这样当我3次触摸任何单元格时,它会向我显示
SFSafariViewController
的预览,他们会带我去点击它们。peek功能工作正常,但一旦移动到弹出状态,它不会在中显示
SFSafariViewController
,而是从上一个视图显示导航控制器,并且显示
SFViewController
的视图尺寸很小

这就是我如何在我的
TableViewController中编程peek和pop功能的方法:

extension MyBlogsTableViewController: UIViewControllerPreviewingDelegate {

func previewingContext(previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
    if let indexPath = tableView.indexPathForRowAtPoint(location) {

            let cell = tableView.cellForRowAtIndexPath(indexPath) as! MyBlogsTableViewCell

            let destinationViewController = SFViewControllerToExplore(indexPath.row)
            destinationViewController.preferredContentSize = CGSize(width: 0.0, height: 0.0)

            previewingContext.sourceRect = cell.frame

            return destinationViewController
    }
    return nil
}

func previewingContext(previewingContext: UIViewControllerPreviewing, commitViewController viewControllerToCommit: UIViewController) {
    navigationController?.pushViewController(viewControllerToCommit, animated: true)
}

private func touchedView(view: UIView, location: CGPoint) -> Bool {
    let locationInView = view.convertPoint(location, fromView: tableView)
    return CGRectContainsPoint(view.bounds, locationInView)
}

private func SFViewControllerToExplore(index: Int) -> UIViewController {
    var destinationController: SFSafariViewController

    destinationController = SFSafariViewController(URL: NSURL(string: identifierOfLinks[index])!, entersReaderIfAvailable: true)

    return destinationController
}

}

我明白了。因此,在以下代码中:

func previewingContext(previewingContext: UIViewControllerPreviewing, commitViewController viewControllerToCommit: UIViewController) {
     navigationController?.pushViewController(viewControllerToCommit, animated: true)
}  
我实际上不应该使用pushViewController,而是应该使用presentViewController

更正代码:

func previewingContext(previewingContext: UIViewControllerPreviewing, commitViewController viewControllerToCommit: UIViewController) {
     navigationController?.presentViewController(viewControllerToCommit, animated: true, completion: nil)
}