Reputation: 2983
I am developing an application of simple slideshow.
Description : In the application I've 5 images stored in an array.Currently I'm displaying the images into a scroll view but I want to show a slideshow of the images stored in the array. how can I do that ? Any tutorials ?
regards
Upvotes: 2
Views: 2115
Reputation: 47241
I'd suggest using an NSTimer, here's some basic code. However the "page" number has to be calculated somewhere, according how you'd like to handle the edge cases, for example: last image in slide show.
Have a look at Apple's example app PageControl, which shows a nice way how to handle memory efficiently in a paging scrollview.
self.slideTimer = [NSTimer scheduledTimerWithTimeInterval:3.0
target:self
selector:@selector(slide)
userInfo:nil
repeats:YES];
...
- (void)slide
{
CGRect frame = scrollView.frame;
frame.origin.x = frame.size.width * nextImagePageNumber;
frame.origin.y = 0;
[scrollView scrollRectToVisible:frame animated:YES];
}
You use the NSTimer class to create timer objects or, more simply, timers. A timer waits until a certain time interval has elapsed and then fires, sending a specified message to a target object. For example, you could create an NSTimer object that sends a message to a window, telling it to update itself after a certain time interval.
Upvotes: 2
Reputation: 22726
Hi You can have NSTimer for sliding images automatically across the scrollview. i.e. you need to programatically scroll the scrollview according to your requirement on the NSTimer basis. You can set the time interval between the sliding of 2 Photos.
Hope this leads you in the correct pathway. If you have further query please leave a comment I will definitely help you for the same.
Upvotes: 1
Reputation: 643
http://lievendekeyser.net/index.php?module=messagebox&action=message&msg%5Fid=1351
Upvotes: 0