无法安装 "GSImageViewerController Pod" 并且无法在 swift 的项目中使用其代码

Unable to to install "GSImageViewerController Pod" and unable to use its code in project in swift

我需要全屏点击图像,因为其中一位开发人员建议这样做 GSImageViewerController pod..

如果我只像 pod "GSImageViewerController" 这样安装 Pod,并在我的项目 swift 文件中“导入 GSImageViewerController”

就像文档说我写了下面的代码

import UIKit
import GSImageViewerController
class ViewController: UIViewController {

@IBOutlet weak var tapImage: UIImageView!

override func viewDidLoad()
{
    super.viewDidLoad()

    let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(imageTapped(tapGestureRecognizer:)))
    tapImage.isUserInteractionEnabled = true
    tapImage.addGestureRecognizer(tapGestureRecognizer)
}

@objc func imageTapped(tapGestureRecognizer: UITapGestureRecognizer)
{

    let imageInfo   = GSImageInfo(image: tapImage.image!, imageMode: .aspectFit)
    let imageViewer = GSImageViewerController(imageInfo: imageInfo)
    navigationController?.pushViewController(imageViewer, animated: true)
}
}

对于图像视图控制器,我添加了导航控制器。所以在这里,如果我点击图像,那么图像会全屏显示。但是如果我点击屏幕上的任意位置或拖出图片然后我无法回到原来的位置为什么?我哪里错了???请帮忙

您应该 present 而不是 push。下面是我项目中的一个工作示例。

let imageInfo = GSImageInfo(image: profileImageView.image!, imageMode: .aspectFit)
let transitionInfo = GSTransitionInfo(fromView: profileImageView)
let imageViewer    = GSImageViewerController(imageInfo: imageInfo, transitionInfo: transitionInfo)
present(imageViewer, animated: true, completion: nil)