2012-10-12 101 views
3

我在我的视图中有3个桌面视图,我想同时为所有表启用滚动顶部功能,例如,如果用户点击状态栏上的所有三个表格应滚动到顶部位置。当状态栏被点击时,将所有滚动视图滚动到顶部

我已经尝试使用所有我的tableViews的滚动触摸属性,也是此属性的是/否的各种组合。例如

table1.scrollsToTop = YES; 
table2.scrollsToTop = NO; 
table3.scrollsToTop = NO; 

但无法实现此目的。我们是否有办法让状态栏点击事件,以便我可以尝试将所有表格的内容偏移量设置为最高位置或任何其他解决方法。

任何帮助,将不胜感激。

+0

有你通过覆盖scrollViewShouldScrollToTop方法如下面选中解决了这个问题,这个问题http://stackoverflow.com/q/1063213/859742 –

+1

, ' - (BOOL)scrollViewShouldScrollToTop:(UIScrollView中*)滚动视图{ [表1 scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0切入口:0] atScrollPosition:UITableViewScrollPositionTop动画:YES]; [table2 scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES]; [table3 scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES]; return NO; }' – MPG

+1

MPG如果可能,请回答您自己的问题并接受您的回答,以便将此问题标记为“已回答”。谢谢! – Kalle

回答

2

通过重写scrollViewShouldScrollToTop方法如下面解决了这个问题, -

- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView { 
    [table1 scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES]; 
    [table2 scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES]; 
    [table3 scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES]; 

    return NO; 
} 
相关问题