重复我的幻灯片放映

时间:2013-11-21 06:55:52

标签: ios sdk

我试图让这个幻灯片重复无限,并没有工作。请帮助我

-(void)viewDidLoad
{

   [super viewDidLoad];
    [NSTimer scheduledTimerWithTimeInterval:15 target:self selector:@selector(changeImage) userInfo:nil repeats:YES]; 
}


-(void)changeImage

{
    [UIView transitionWithView:imageView duration:5 options:UIViewAnimationOptionTransitionFlipFromBottom animations:^{
    imageView.image = [UIImage imageNamed:@"6.png"];
} completion:^(BOOL done){
    [UIView transitionWithView:imageView duration:5 options:UIViewAnimationOptionTransitionFlipFromBottom animations:^{
        imageView.image = [UIImage imageNamed:@"2.png"];
    } completion:^(BOOL done){
        [UIView transitionWithView:imageView duration:5 options:UIViewAnimationOptionTransitionFlipFromBottom animations:^{
            imageView.image = [UIImage imageNamed:@"3.png"];
        } completion:^(BOOL done){
        }];
    }];
}];
}

2 个答案:

答案 0 :(得分:4)

而不是这样做你可以使用UIImageview的内置属性来制作动画图像。

你可以尝试类似的东西,

NSArray *images = [NSArray arrayWithObjects:
[UIImage imageNamed:@"6.png"],
[UIImage imageNamed:@"2.png"],
[UIImage imageNamed:@"3.png"],
nil];

imageView.animationImages = images;
imageView.animationDuration = 1;
imageView.animationRepeatCount = 0; // 0 = nonStop repeat
[imageView startAnimating];

答案 1 :(得分:1)

您可以通过示例获取此内容:http://goo.gl/8Gj6m0