gpt4 book ai didi

cocoa-touch - 在 ImageView 之间暂停

转载 作者:行者123 更新时间:2023-11-28 19:24:31 26 4
gpt4 key购买 nike

我想运行一系列带有对话泡泡的图片(比如脱衣舞卡通)。我尝试使用该操作:

-(IBAction) runDialog:(id)sender {
imageView.image = [UIImage imageNamed:@"a1.png"];
[NSThread sleepForTimeInterval:5.0];
imageView.image = [UIImage imageNamed:@"b1.png"];
[NSThread sleepForTimeInterval:5.0];
imageView.image = [UIImage imageNamed:@"b2.png"];
[NSThread sleepForTimeInterval:5.0];
imageView.image = [UIImage imageNamed:@"a2.png"];
[NSThread sleepForTimeInterval:5.0];
}

这行不通。它所做的只是在大约 20 秒后显示最后一张图像 (a2.png)我应该如何解决这个问题:显示一系列中间有停顿的图片?

最佳答案

改用 NSTimer。

- (IBAction)runDialog:(id)sender {
yourInstanceVariableOfNSTimer = [NSTimer scheduledTimerWithTimeInterval:5.0f
target:self selector:@selector(showNextPage) userInfo:nil repeats:NO];
}
- (void)showNextPage {
imageView.image = [yourInstanceVariableOfNSArray
objectAtIndex:++yourInstanceVariableOfNSInteger];
if (!transitionsFinished) {
yourInstanceVariableOfNSTimer = [NSTimer scheduledTimerWithTimeInterval:5.0f
target:self selector:@selector(showNextPage) userInfo:nil repeats:NO];
}
}

关于cocoa-touch - 在 ImageView 之间暂停,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5006802/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com