0
我目前有一個橫幅可以從我的網站獲取圖片,我可以滾動左側的橫幅並獲得下一張或上一張圖片的權限。不過,我也希望它每5秒自動更換一次圖像。如何在UIView中每5秒換一張圖片?
我試着將這些代碼添加到imageView,但橫幅變爲空,不顯示任何圖像。
imageView.animateImages = delegate.bannerDetailsArray;
imageView.animationDuration = 5.0;
imageView.animationRepeatCount = 0;
[imageview startAnimating];
我猜數組是問題所在,但我目前還不知道如何解決它。
任何人都可以切碎一些燈如何使橫幅圖像每5秒更換一次?
-(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];
*以上代碼在忽略動畫部分時工作正常。 謝謝
謝謝。我現在有一種工作方式。我在imageView中添加了一個NStimer,現在每5秒觸發一次。 – Kevin