2
我有三個圖像。它們應該像從動輪一樣每4秒從右到左進行動畫製作。如果用戶拖動到第二張圖像,那麼在4秒鐘後從第2 - 第3張開始滑動。如何實現這一點?使用nstimer在無限滾動視圖中滑動圖像
currntly我使用下面的代碼,但它不按預期工作。
[NSTimer scheduledTimerWithTimeInterval:4.0 target:self selector:@selector(doAnimation) userInfo:nil repeats:YES];
-(void)doAnimation
{
if (currentPage) {
[self scrollFromCurrentpage];
return;
}
//CGPoint p=CGPointMake(count*320, 0);
if (count==3) {
count=0;
[_scrollView setContentOffset:CGPointMake(0, 0)animated:NO];
return;
}
count++;
[UIView animateWithDuration:2.0 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^
{
CGRect rect= CGRectMake(count*320, 0, 320, 352);
[_scrollView scrollRectToVisible:rect animated:NO];
}completion:^(BOOL finished)
{
}];
}
-(void)scrollFromCurrentpage
{
[UIView animateWithDuration:2.0 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^
{
CGRect rect= CGRectMake(currentPage*320, 0, 320, 352);
[_scrollView scrollRectToVisible:rect animated:NO];
currentPage=0;
}completion:^(BOOL finished)
{
}];
}
給我適當的執行 – MuraliMohan