如何检测哪个UITableView正在滚动

时间:2013-05-29 07:11:53

标签: ios uitableview scroll

我以这种方式检测UITableView滚动

`

  - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate: (BOOL)decelerate{
isDragging_msg = FALSE;
[tblSongs reloadData];

}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
isDecliring_msg = FALSE;
[tblSongs reloadData]; }


- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
isDragging_msg = TRUE;

}

 - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{
isDecliring_msg = TRUE; }

`

但我必须加载sevaral UITableViews在此检测下,我必须单独重新加载每个表。所以我如何检测当前正在滚动的表。

由于

3 个答案:

答案 0 :(得分:8)

表视图是这里提到的滚动视图:Is it possible to access a UITableView's ScrollView In Code From A Nib?

因此,您可以检查每个委托方法中传递的滚动视图,无论滚动视图是您想要的表视图,例如:

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
    if (scrollView == tblSongs) {
        isDragging_msg = FALSE;
        [tblSongs reloadData];
    }
}

答案 1 :(得分:0)

您认为所有这些方法中的scrollView参数是什么?

答案 2 :(得分:0)

您可以检测每张桌子上的事件。 UITableView event

要在UITableView上使用触摸事件:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
  //<your stuff>

  [super touchesBegan:touches withEvent:event];
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
   //<your stuff>

   [super touchesMoved:touches withEvent:event];
}

- (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
{
  //<your stuff>

  [super touchesEnded:touches withEvent:event];
}

- (void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event
{
   //<your stuff>
   [super touchesCancelled:touches withEvent:event];
}

并可以重新加载任何特定的tableview。感谢