开发者

Pausing between image views

I want to run a series of pictures with dialog bubble (like a strip cartoon). I've tried to use the action:

-(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];
}

This doesn't work. All it does is show the last image (a2.png) After About 20 seconds Any ideas how I should go about this:showing a series of pictures with a pause in between?


Use NSTimer instead.

- (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];
    }
}


A simpler way to handle this would be to use a UIImageView in the dialog and set its animationImages, animationDuration, etc... properties.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜