I have been trying to display large image from server, but I have to display it progressively.
I used subclass of UIView and in that I have taken UIImage
object, in which I used NSURLConnection and its delegate methods, I also used
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data;
in which I am appending data and converting it to UIImage
object, and drawing rect using the drawInRect:
method of UIImage
.
Everything is working fine, but the problem is, when image is being drawn on context, I cannot click anywhere else on screen until entire image is being drawn on to screen.
Is there any good solution, where I can click anywhere else even if image is being drawn on screen?
Any help will be appreciable.
Edit:
Is there any efficient way of drawing image blurry progressively in didReceiveData
? so drawInRect
does not take too much time to draw. Or If anyone has custom drawRect
method which efficiently displays image progressively as data received in didReceiveData
.
UIImage contains the data for an image. UIImageView is a custom view meant to display the UIImage .
For example: UIImage *img = [[UIImage alloc] init]; [img setImage:[UIImage imageNamed:@"anyImageName"]]; My UIImage object is declared in .
Overview. Image views let you efficiently draw any image that can be specified using a UIImage object. For example, you can use the UIImageView class to display the contents of many standard image files, such as JPEG and PNG files.
An object that manages image data in your app.
I have used NYXImagesKit for something similar, downloading images while not blocking the main thread and showing the image progressively. Ive written a really quick and dirty example to illustrate the basic workings. I load the image in a UITableview to show that it doesn't block the User Interface(Main Thread). You can scroll the tableview while the image is loading. Don't forget to add the correct Frameworks, there are a few. Heres the link to the project on Github:
https://github.com/HubertK/ProgressiveImageDownload
It's really easy to use,create a NYXProgressiveImageView object, set the URL and it will do all the work for you when you call:
loadImageAtURL:
It's a subclass of UIImageView, Works like magic! Here's a link to the developers site:
http://www.cocoaintheshell.com/2012/01/nyximageskit-class-nyxprogressiveimageview/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With