I'm trying to use threading to load an image from a url. I have no background code and I'm having trouble getting the NSThread thing to work. What I've got is a UIimageView called photo1 and I've got an image that loads in from the net. (say http://www.google.com/logos/classicplus.png) but when navigating to the screen, the app pauses to load the image before h开发者_StackOverflow社区and. I was told to use NSThread to achieve this (watching the stanford U tutorial on it) but I'm having no luck at all getting it to work.
Any help would really be appreciated.
I would suggest that you don't use an NSThread
to accomplish this, but rather use an asynchronous NSURLConnection
.
Using the asynchronous URL connection won't block the UI, but will be much easier to use than maintaining all the boilerplate code required for an NSThread
.
Look up the documentation for NSURLConnection
, the parts you're interested in mainly are the bits on how to create an asynchronous connection and the delegate call backs.
精彩评论