Networked Image View
Sometime it is preferred that the image that gets displayed in an iPhone app is downloaded from the internet, much like an image in a web page. In order to make displaying a networked image as simple to accomplish as the UIKit's
The biggest challenge in this class is handling the fact that there is a noticeable lag time between issuing the request to download an image's data from a URL and when you can actually draw the image to the view. It would be a poor design to do this work synchronously in the main event loop of an app, as the app's UI would effectively lock up. In order to perform the downloading work asynchronously,
The MKNetworkImageView class is available on GitHub.
UIImageView
, I created the MKNetworkImageView
class. The biggest challenge in this class is handling the fact that there is a noticeable lag time between issuing the request to download an image's data from a URL and when you can actually draw the image to the view. It would be a poor design to do this work synchronously in the main event loop of an app, as the app's UI would effectively lock up. In order to perform the downloading work asynchronously,
MKNetworkImageView
spawns a new thread when the image URL is set, and it is on this thread that the work of downloading the image data is done. When the image's data is fully downloaded, the spawned thread then set's the view's image back on the main thread.The MKNetworkImageView class is available on GitHub.
blog comments powered by Disqus