Obj C - 如何使用 IKSlideShow 自定义幻灯片之间的间隔

发布于 2024-09-05 00:34:41 字数 505 浏览 3 评论 0原文

我对 Objective-C 和 Cocoa 很陌生,但我制作了一个简单的应用程序,它使用 ImageKit 使用 IKSlideShow 类来呈现幻灯片。然而,我对一些我认为很简单的事情有点困惑。我想增加幻灯片播放时照片在屏幕上显示的时间,但我不知道如何有效地做到这一点。

IKSlideshowDatasource 协议允许您在“slideshowDidChangeCurrentIndex”时执行操作,这似乎是执行此操作的最佳位置 - 但是我尝试在这里放置各种延迟,例如:

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

但是它们会阻止用户在幻灯片上手动移动或离开幻灯片幻灯片。

非常感谢任何建议。谢谢!

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 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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

悟红尘 2024-09-12 00:34:42

如果其他人想知道,可以这样做(尽管不确定我是否会推荐我的方法,因为使用私有 API)。

如果您使用 classdump 提取 IKSlideShow 的头文件,您将了解到 IKSSSPanel.h 控制屏幕上的播放、暂停等按钮,而 IKSlideShowHandler.h 控制幻灯片。在您的项目中包含这两个标头。

如果您随后重写单击播放按钮时调用的 IKSSPanel 方法,则可以进入该方法,并更改控制幻灯片显示时间的 autoPlayDelay 值,然后使用幻灯片处理程序的 StartAutoPlay 方法开始幻灯片放映。

可能有一个更干净的解决方案,但这似乎对我来说效果很好。

#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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文