i'm having array of image urls (say count=10), i have to display the images in NSCollectionView. but the images were took lot of time to display. what is lazy loading? i'm searching for mac osx not IOS.
If your images are not downloaded you can still show your view. You just display some placeholder, or an activityIndicator instead of each image, and when each of your images finishes downloading, you replace your placeholder with the correct image. Just make sure to download your images on an background thread and perform the replacing on the main thread. I recommend using NSOperationQueue for downloading on an background thread.
Download files asynchronously .So that it wont affect the main thread.
Lazy loading is a design pattern commonly used in computer programming to defer initialization of an object until the point at which it is needed.
that is when the image is visible only it needs to be loaded.So do it that way.Collectionview and tableview populates in such a way itself
Related
In my project i have about 100 images all tiled to display large zooms with CATiled methods. These are a lot of files that, if put in a local bundle, rapidly make the app bundle too big.
I want to load these files from a web repository, using SDWebImage or any other sdk.
Can you suggest any method to achieve this? Please keep in mid we are not talking of loading a single image, or multiple images for a UITableView, but lots of little tiled images that will be used when the user make zoom in a given view, and therefore this tiles have no UIImageview object to hold them, they are just in the bundle (now).
We are using ios7.
Thank you in advance.
I'm making a simple game and just messing around with SDL. I have two images currently, and I am practicing making them the background. I make one the background by calling RenderCopy, the DestroyTexture to clear it from memory, and then I present it. I changed the file path from one image to the other to change the background. I ran the program, and now the new image is layered on top of the other. I can fix this problem if I manually do a clean of my computer's memory, and it renders properly. For some reason, SDL is not clearing the image called previously. There is no mention of the old image anywhere else in the code, and all the Destroy functions are called. What is going on?
Edit: I did a little bit of snooping and its not that it even loads the old image; whatever the final render displayed on any program running SDL was before it was run, it will be the background. It is literally like a TV burning an image into the screen; its always there.
The problem was fixed by simply clearing the frame between frames. Didn't have any performance impact.
I am setting a background image on my XAML Grid with a Uri. The Uri points off to a HTTP url, where it will fetch, and then render the image as a background for a Win8 metro app.
I've been trying to figure out if there is an event or something I can hook into to let me know that WPF has loaded it into memory, AND finished rendering it out of view.
Currently, a small image will load fast enough, and smoothly fade in. However, if I load a larger, slower image, it will take 100s of ms to show up as the background, which means it either pops up mid-fade, or after the fade effect has completed. This looks quite poor.
The goal is to have a fade transition between app pages (I already have this), without the inconsistency of the background image popping up whenever it's done.
Any suggestions would be welcomed.
You don't say exactly how you're loading the image but there's a DownloadCompleted event on BitmapImage, e.g.
BitmapImage bmp = new BitmapImage(imageUri);
bmp.DownloadCompleted += ReadyToDisplay;
Like Phil said, but then for Windows Store apps:
BitmapImage bmp = new BitmapImage(imageUri);
bmp.ImageOpened += ReadyToDisplay;
ImageOpened Occurs when the image source is downloaded and decoded
with no failure. You can use this event to determine the size of an
image before rendering it.
source: MSDN
One of the ways to improve user experience in iOS while showing images is to download them asynchronously without blocking the main thread and showing them....
But I want to add something to this -
Initially when there is no image,show a spinner while the async download has started.
After the download cache the image on local iOS disk for later use.
After the download populate the image part of UIImageView.
And dont just plonk the image into view for user. Showly Fade in the user (i.e. from alpha 0.0 to 1.0)
I have been using SDWebImage for sometime now. It works well but does not satisfy my 1st requirement (about spinner) and 4th.
Is there any help out there to satisfy all this?
Three20 http://www.three20.info has a TTImageView class that statisfies 2-3, you can subclass it and overwrite setImage: and create the fade animation there. (or just modify TTImageView.m directly).
Spinner is easy as well when you modify TTImageView you can add a TTActivityView on top and remove it on setImage:
I'm coding an application on Ipad, in a certain point of my application I present a ViewController with the presentModalViewController.
My ViewController is a UISScrollView who take the larger of the modalView and inside it I display some images, I allow pagingEnabled so I can see all my images inside the scrollView.
Sometimes I have to display more than 10 images inside the scrollView, so I have this error
RECEIVE MEMORY WARNING LEVEL=1 after this one RECEIVE MEMORY WARNING LEVEL=2 and finnaly the debugger exited due to signal 10 (Sigbus).
What can I do? is there a way to unload the image thats offscreen? or others things to do?
Thanks,
I guess you're adding all the images to the UIScrollView? Then the iPad has to keep all 10 images in memory. If they are full screen images, each of them will take up about 3 MB of memory, so you're using 30MB just to keep the 10 images in the scroll view.
You should only add the one or two images that are actually visible. Once they scroll out of sight, remove the UIImageView from your UIScrollView (and make sure you don't retain it anywhere else so it can be deallocated). When a new image scrolls into sight, add it to the UIScrollView only then.
In your UIScrollViewDelegate method -scrollViewDidScroll: get the current contentOffset and use that to calculate which images are visible.
Actually, this problem is even worse on the iPhone 3G, which can't even manage to display two full size photos (taken with it's own camera) at the same time.
If you can make the photos smaller ahead of time by resizing them (server side if you're snagging them from your own services, or client side if they're somehow generated on the device or retrieved from third party services), you should. They will load faster, and you can put more of them on the screen at once without running into memory issues.
The Three20 library has a really great photo-browsing control for the iPhone. I'm pretty sure they only have three photos around at any given time... the photo you're looking at, and the photos going forward or backwards.
http://github.com/facebook/three20
I also think there is an iPad branch of the Three20 controls (at ./tree/ipad), although I don't know if they include the photo browser or not, and haven't tried them yet myself... maybe that's an option for you if you don't want to spend a lot of time on that particular feature of your application. If the iPad photo browser isn't done maybe you could just adapt the iPhone version to suit your needs (shouldn't be hard).
If you want to bake the feature yourself, I'd take some inspiration from the UITableViewController. Your controller should come with associated datasource and delegate protocols to retrieve photos and respond to user events. The controller base class itself should reuse three UIImageViews and should shuffle those around to create the illusion that the user is scrolling through a large list.