I have a banner currently that gets images from my site, and I can scroll the banners left and rights to get the next or previous image. However, I also want it to change the images automatically every 5 secs.
I tried adding these codes to imageView, but the banner becomes empty not showing any images.
imageView.animateImages = delegate.bannerDetailsArray;
imageView.animationDuration = 5.0;
imageView.animationRepeatCount = 0;
[imageview startAnimating];
I am guessing that the array is where the issue is, but I am currently no clue how to fix it.
Can anyone shred some lights how to make the banner images change every 5 seconds?
-(void) bannerSettings
{
bannerScrollView = [UIScrollView new];
[bannerScrollView setBackgroundColor:BackGroundColor];
[bannerScrollView setFrame:CGRectMake(0,0,delegate.windowWidth, [self imageWithImage:delegate.windowWidth maxHeight:200])];
[bannerScrollView setPagingEnabled:YES];
[bannerScrollView setContentSize:CGSizeMake([delegate.bannerDetailsArray count]*delegate.windowWidth, 0)];
NSLog(@"%@",delegate.bannerDetailsArray);
for(int i=0;i<[delegate.bannerDetailsArray count];i++)
{
UIImageView * imageView = [UIImageView new];
[imageView setFrame:CGRectMake(i*delegate.windowWidth,0,delegate.windowWidth,[self imageWithImage:delegate.windowWidth maxHeight:200])];
[imageView sd_setImageWithURL:[NSURL URLWithString:[[delegate.bannerDetailsArray objectAtIndex:i]objectForKey:@"bannerImage"]]];
[imageView setContentMode:UIViewContentModeScaleAspectFill];
[imageView.layer setMasksToBounds:YES];
[imageView setUserInteractionEnabled:YES];
[imageView setTag:i];
//imageView.animateImages = delegate.bannerDetailsArray;
//imageView.animationDuration = 3.0;
//imageView.animationRepeatCount = 0;
//[imageview startAnimating];
[bannerScrollView addSubview:imageView];
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(bannerGestureTapped:)];
[imageView addGestureRecognizer:singleTap];
*The above codes works fine when the animation part ignored. Thank you