如果滚动或不滚动,IOS知道何时完成NSTable scrollToRowAtIndexPath

时间:2013-06-04 19:43:44

标签: ios nstableview

如果滚动或不滚动,需要知道scrollToRowAtIndexPath何时完成。

无法使用滚动例程,因为行已经就位并且表格没有滚动。

如果可能,不想使用某些计时器/失效来执行此操作。

2 个答案:

答案 0 :(得分:0)

在致电[tableView scrollToRowAtIndexPath:indexPath...之前,请执行以下操作:

BOOL visible = NO;
for (UITableViewCell *cell in [tableView visibleCells])
    if ([indexPath isEqual:[tableView indexPathForCell:cell]]) {
        visible = YES;
        break
    }

如果需要,可以将视图存储为视图控制器的成员变量,以便在处理某种委托方法时检查其值。

答案 1 :(得分:0)

原来必须使用NSTimer等。以下是它如何发展......如果有人有更好的方法......

In routine that tells the indexPath to scroll to
 Scroll to IndexPath
 tableMoving = true
 set NSTimer to fire MovingDone at 0.1

In scrollViewDidScroll
 if tableMoving
   invalidate timer
   timer = nil

In scrollViewDidEndScrollingAnimation
 if tableMoving
    call MovingDone

In MovingDone
 moving = false
 // do end of table scrolling code here