Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS:UIImageView幻灯片放映_Ios_Objective C_C - Fatal编程技术网

iOS:UIImageView幻灯片放映

iOS:UIImageView幻灯片放映,ios,objective-c,c,Ios,Objective C,C,对于iOS应用程序,我希望UIImageView在幻灯片中有多个图像。我还希望能够选择动态的活动照片。有没有一个简单的方法可以做到这一点?(具体的代码会很好,但一两个提示也会很感激) 谢谢 我为此制作了一个小型库,非常灵活,有很多选项: - (void)awakeFromNib { timer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(updatePhoto) userInfo

对于iOS应用程序,我希望UIImageView在幻灯片中有多个图像。我还希望能够选择动态的活动照片。有没有一个简单的方法可以做到这一点?(具体的代码会很好,但一两个提示也会很感激)


谢谢

我为此制作了一个小型库,非常灵活,有很多选项:

- (void)awakeFromNib {
    timer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(updatePhoto) userInfo:nil repeats:YES];
    count = 0;
}
// this creates a loop every 0.5 secs.
// then set up your image changes.

-(void)updatePhoto{
    count = count + 1;
    [self updateImage];
}

-(void)updateImage{
    if (count == 1){
        mainImage.image = [UIImage imageNamed:@\"img2.jpg\"];
    }
    if (count == 2){
        mainImage.image = [UIImage imageNamed:@\"img4.jpg\"];
    }
    if (count == 3){
        mainImage.image = [UIImage imageNamed:@\"img3.jpg\"];
    }
    if (count == 4){
        mainImage.image = [UIImage imageNamed:@\"img3.jpg\"];
    }
    else{
        mainImage.image = [UIImage imageNamed:@\"img1.jpg\"];
    }

}
一个简单的幻灯片声明如下所示:

_slideshow.delegate = self;
[_slideshow setDelay:1]; // Delay between transitions
[_slideshow setTransitionDuration:.5]; // Transition duration
[_slideshow setTransitionType:KASlideShowTransitionFade]; // Choose a transition type (fade or slide)
[_slideshow setImagesContentMode:UIViewContentModeScaleAspectFill]; // Choose a content mode for images to display
[_slideshow addImagesFromResources:@[@"test_1.jpeg",@"test_2.jpeg",@"test_3.jpeg"]]; // Add images from resources
[_slideshow addGesture:KASlideShowGestureTap]; // Gesture to go previous/next directly on the image