开发者

Obj C - how to customise the interval between slides with IKSlideShow

开发者 https://www.devze.com 2023-01-03 14:36 出处:网络
I\'m very new to Objective-C and Cocoa but I\'ve made a simple app which uses ImageKit to present a slideshow using the IKSlideShow class. However I\'ve got a bit stuck with something I thought would

I'm very new to Objective-C and Cocoa but I've made a simple app which uses ImageKit to present a slideshow using the IKSlideShow class. However I've got a bit stuck with something I thought would be simple. I want to increase the time photos are displayed on screen when the slideshow is playing, but I can't see how to do it effectively.

The IKSlideshowDatasource protocol lets you do stuff when "slideshowDidChangeCurrentIndex" which seems to be the best place to do this - however I've tried putting various delays in here such开发者_JAVA技巧 as:

while ( functionShouldPause )
    {
        [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:20]];
        functionShouldPause=NO;
    }

However they prevent the user for manually moving on the slides, or leaving the slideshow.

Very grateful for any suggestions. Thanks!


In case anyone else wants to know, this can be done (though not sure I would recommend my method since uses private APIs).

If you use classdump to extract the header files for IKSlideShow, and you will learn that IKSSPanel.h controls the onscreen play, pause, etc. buttons, and that IKSlideShowHandler.h controls the slideshow. Include both headers in your project.

If you then override the IKSSPanel method called when the play button is clicked, you can get in there, and change the autoPlayDelay value that controls how long the slide is displayed, then kick off the slideshow by using the slideshow handler's StartAutoPlay method.

There is probably a much cleaner solution, but this seems to be working well for me.

#import "IKSSPanelUtils.h"


@implementation IKSSPanel (utils)

- (void)slideshowPlay:(id)sender
{
    NSLog(@"This method overrides the IKSSPanel SlideshowPlay method");
    NSLog(@"Setting the autoPlayDelay to 20 seconds");

    _slideshowHandler.autoPlayDelay=20;
    [_slideshowHandler startAutoPlay];

}
@end
0

精彩评论

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