iOS知道何时滚动页面标题

时间:2013-07-30 21:20:59

标签: iphone ios objective-c uiscrollview

我正在开发一个iPhone应用程序,我希望在下一个部分标题被推出时,可以执行一些自定义行为。有什么办法可以告诉scrollViewDidScroll发生这种情况吗?

谢谢,

2 个答案:

答案 0 :(得分:0)

您可以使用rectForHeaderInSection获取任何部分的实际位置:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView_ {
    ...
    CGRect rect = [mytable convertRect:[mytable rectForHeaderInSection:0] toView:[mytable superview]];
    ...
}

要实现您在scrollViewDidScroll中提到的内容,您可以遍历所有部分(如表中所定义)并检查rect.origin.y以获取它是否为负值(在可见区域之外)或不

希望它有助于作为详细实施的开始思考! Check reference also.

答案 1 :(得分:0)

如果您定位iOS 6及更高版本,则可以使用tableView:didEndDisplayingHeaderView:forSection:中的UITableViewDelegate方法:

- (void)tableView:(UITableView *)tableView didEndDisplayingHeaderView:(UIView *)view forSection:(NSInteger)section
{
  // do what you need
}