开发者

UIScrollView question... loading images

I have a UIScrollView that does not do paging. I am loading about 500 small (64x64-iPhone 192x192-iPad) images. I do not want to load them all into memory. I would like to load them as the user scrolls.

Can anyone tell me where I can set the images to display? I have an object for each image that holds the image resource name, index number and x and y coordinate where it should be displayed in the UIScrollView. I was hoping there was a method I could override where I could create a UIImageView and then add the view to the scroll view on the fly... maybe preloading 6 to 10 images at a time. Every sample I see uses paging and only displays one image at a time.

Any help or example is greatly appreciated.

Thank you

EDIT:

In the ScrollViewSuite examples from Apple there is a Tiling example. That example has a scrollview that popups up displays ima开发者_JAVA百科ges to select from. That is exactly what I am trying to do, but Ineed to load them on the fly. The sample loads all of the thumbnail images into memory. Someone somewhere must be doing this because the iPod/iPhone and iPad do not have alot of memory to load all the images.


Apple has some really good demo code that shows how to do this. Check out TiledScrollView.m especially the layoutSubviews method.


write the code in following method of scrollview:

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView

I did the same. Load atleast few images in the beginning and then load those images in above method.

PROPERLY ALLOC AND RELEASE IMAGEVIEWS SINCE THEY CAN LEAD TO MEMORY LEAKS

Hope this works for you :) Cheers :)


Couldn't you just use a UITableView for this?

Edit: Might be worth looking at


u can try making ur tableview horizontal by using CAAffinneTransform and giving the angle as (3.14/2) ie 90 degree annd can have a horizontal tableview with horizontal scroll and can use the above refrence given by MIKE A regards...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜