如何在iphone中同时滚动两个表视图但在不同的时间间隔?

时间:2013-09-12 10:41:10

标签: iphone

-(void)viewDidLoad
{
    [NSTimer scheduledTimerWithTimeInterval: 0.035 target:self selector:@selector(scrollTableView) userInfo:nil repeats:YES];
    [NSTimer scheduledTimerWithTimeInterval: 0.065 target:self selector:@selector(scrollTableView1) userInfo:nil repeats:YES];
}

-(void) scrollTableView 
{    
    float w = 1;
    CGPoint scrollPoint = leftTable.contentOffset;
    scrollPoint.y = scrollPoint.y + w;
    if (scrollPoint.y >= leftTable.contentSize.height - (leftTable.frame.size.height - 100)  || scrollPoint.x <= -leftTable.frame.size.height + 924) {
        w *= -1;
    }
    [leftTable setContentOffset:scrollPoint animated: NO];
}

-(void) scrollTableView1 
{
    float w = 1;
    CGPoint scrollPoint = rightTable.contentOffset;
    scrollPoint.y = scrollPoint.y + w;
    if (scrollPoint.y >= rightTable.contentSize.height - (rightTable.frame.size.height - 100)  || scrollPoint.x <= -rightTable.frame.size.height + 924) {
        w *= -1;
    }
    [rightTable setContentOffset:scrollPoint animated: NO];
}

我正在使用这个代码它工作得很好,两个表视图在我想要的不同持续时间滚动,但当我拖动任何一个表视图而另一个表视图停止滚动。我想如果我拖动一个表视图另一个一个应按预定的时间间隔滚动。

0 个答案:

没有答案