1

Bach displays in a .playground file but is gray. Toggling different Result Display Modes did not help.

enter image description here

import UIKit import PlaygroundSupport PlaygroundPage.current.needsIndefiniteExecution = true URLCache.shared = URLCache(memoryCapacity: 0, diskCapacity: 0, diskPath: nil) var theImage = UIImageView() let urlNew = NSURL(string: "https://upload.wikimedia.org/wikipedia/commons/6/6a/Johann_Sebastian_Bach.jpg") let task = URLSession.shared.dataTask(with: urlNew! as URL) { (data, response, error) -> Void in if error != nil { print("thers an error in the log") } else { DispatchQueue.main.async() { let image = UIImage(data: data!) theImage.image = image } } } task.resume() 

What is the best way to render Bach or any UIImageView in a .playground with Swift 3.0?

3
  • What have you tried so far? It's obviously downloading the proper image, it may just be a UI bug in playgrounds. You should also be able to skip the UIImageView and just display the UIImage directly. Commented Mar 8, 2017 at 3:41
  • I tried. Updating the code from UIImageView to UIImage has no effect on the gray shading. Commented Mar 8, 2017 at 3:56
  • I'm not in front of my computer just now, but I'll try to reproduce the issue later tonight. Commented Mar 8, 2017 at 4:16

1 Answer 1

3

I figured out the issue you're seeing, and created a playground here to illustrate: https://github.com/dtweston/Bach.playground

import UIKit import PlaygroundSupport // Toggle the code below to fade the image out or display it properly //PlaygroundPage.current.needsIndefiniteExecution = true let image = UIImage(named: "Johann_Sebastian_Bach.jpg") 

Basically, the image appears faded while the playground is still running. Since you have needsInfiniteExecution set to true, it always appears faded.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.