无法安装"GSImageViewerController Pod";并且无法在项目中快速使用其代码 [英] Unable to to install "GSImageViewerController Pod" and unable to use its code in project in swift

查看:76
本文介绍了无法安装"GSImageViewerController Pod";并且无法在项目中快速使用其代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要全屏点击图像,因为开发人员之一建议使用 GSImageViewerController容器.

I need tapped image in full screen for that one of the developer suggested this GSImageViewerController pod..

如果我仅像 pod"GSImageViewerController" 这样安装Pod并"import GSImageViewerController"在我的项目的快速文件中

if i install the pod only like pod "GSImageViewerController" this and "import GSImageViewerController" in swift file in my project

就像文档所说的,我已经在下面的代码中写了

and like documentation said i have written below code

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)
}
}

对于imageview控制器,我已经添加了navigationcontroller ..所以在这里,如果我点击图像,则全屏显示图像..但是就像文档所说,如果我在屏幕上的任意位置点击或拖出图像,那么我就是为什么不能回到原来的位置?我在哪里错了???请帮忙

推荐答案

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

Instead of push you should do present. Below is a working example from my project.

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)

这篇关于无法安装"GSImageViewerController Pod";并且无法在项目中快速使用其代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆