0

Using a Photo viewer that displays a photo from a collectionView. Can anyone tell me why the viewer is completely ? The image doesn't get displayed at all. I just get a blank screen. In my storyboard, I have an image view with an outlet in my view controller... Why is nothing getting displayed ?

import UIKit
import QuartzCore
import Alamofire
import AlamofireImage

class PhotoViewerViewController: UIViewController, UIScrollViewDelegate {

    let goldenWordsYellow = UIColor(red: 247.00/255.0, green: 192.00/255.0, blue: 51.00/255.0, alpha: 0.5)

    var imageURLForViewerController: String = ""

    @IBOutlet weak var imageView: UIImageView!

    let spinner = UIActivityIndicatorView(activityIndicatorStyle: .White)

    var photoInfo: PictureElement?

    override func viewDidLoad() {
        super.viewDidLoad()

        setupView()
        loadPhoto()
    }

    func setupView() {
        spinner.center = self.imageView.center
        spinner.color = goldenWordsYellow
        spinner.hidesWhenStopped = true
        spinner.startAnimating()
        view.addSubview(spinner)

        let doubleTapRecognizer = UITapGestureRecognizer(target: self, action: "handleDoubleTap:")
        doubleTapRecognizer.numberOfTapsRequired = 2
        doubleTapRecognizer.numberOfTouchesRequired = 1
        view.addGestureRecognizer(doubleTapRecognizer)
    }

    func loadPhoto() {

        let image = UIImage(named: "AppIcon")

        self.imageView.image = UIImage(named: "AppIcon")
        self.imageView.frame = self.view.frame
        self.view.bringSubviewToFront(imageView)
        self.spinner.stopAnimating()
    }

    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)

        if photoInfo != nil {
            navigationController?.setToolbarHidden(false, animated: true)
        }
    }

    override func viewWillDisappear(animated: Bool) {
        super.viewWillDisappear(animated)
        navigationController?.setToolbarHidden(true, animated: true)
    }
Jack Berstrem
  • 535
  • 1
  • 5
  • 22
  • Try adding the extension to the image name. Ex. "AppIcon.png" or which ever the extension is of the image. – Yan Nov 01 '15 at 03:52

1 Answers1

0

Try by including the app icon size like these "AppIcon29x29". It works for me. Hope this help! Thanks

imageView.image = UIImage(named: "AppIcon29x29") 

or

imageView.image = UIImage(named: "AppIcon40x40")

or

imageView.image = UIImage(named: "AppIcon60x60")
ThetNaing Mizo
  • 4,049
  • 2
  • 14
  • 15
  • `self.imageView.image = UIImage(named: "AppIcon")` as you can see the original question already has the code you've provided. – Alexander M. Sep 01 '16 at 04:17
  • @Alexander Mayatsky ... Please see my answer carefully and see the difference between "AppIcon" and "AppIcon29x29" , "AppIcon40x40", "AppIcon60x60". It really works for me on my projects. Thank you – ThetNaing Mizo Sep 01 '16 at 12:39
  • Yes, you are correct, this is indeed a way to get an AppIcon as opposed to image from assets. You should at least give an explanation then :) Here is another answer precisely describing this case: http://stackoverflow.com/a/22808666/3792318 – Alexander M. Sep 01 '16 at 15:53
  • Glad to hear that this works for you. And also, I am really sorry for my poor english. Then, please remove down vote. So that it can be helpful for others. Thank you so much for your quick reply – ThetNaing Mizo Sep 01 '16 at 16:19