开发者

how to reload a view again and again

开发者 https://www.devze.com 2023-01-11 01:58 出处:网络
hi i am a new iphone programmer i am creating a imagedisplay type application where i have to display imageson a view and by presssing a next buttona new image should appear on same view (i am using

hi i am a new iphone programmer i am creating a imagedisplay type application where i have to display images on a view and by presssing a next button a new image should appear on same view (i am using database)... therefore i need to reload my current view again and again...each time when i click that button.... i tried some suggesion which are given on this website but not satisfied because many开发者_开发知识库 of them are based on timer... please help.....


May be I have missed something in your question. But why you need to reload the entire view? You are using an UIImageView to display your image, right? And you are not showing any kind of scroll, but only a next button, right? Then why don't you just set the image property of UIImageView when the button is tapped.

// in button handler
myImageView.image = [UIImage imageNamed:@"new_image.png"];


Perhaps you could use a paged UIScrollView with three uIImageViews and always have the previous, current and next image loaded. This way when the user hits next, it scrolls animated to the next image. When page 3 is loaded, it programmatically sets the second image view as the desired next image, sets the image you came from on the first image view, and sets the scroll view non-animated to page two and loads the next image in the third image view.

Sounds complicated but basically you are giving the appearance of an infinite scroller but only pulling one image at a time except for initial load of three.


You could try looking at the "PageControl" Example Project in the XCode Documentation. It should give you a good starting point.

0

精彩评论

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