2012-11-27 56 views
0

UI表视图第一小区在我的申请我有一个表视图,并用三个按钮的段,如何设置在顶部

每个按钮动作填充在同一个表和重装每次不同的阵列,

当我在第三段,当我滚动填充coresponding第三段数据的表,

并返回BAK到第一,第二区段室内用它们各自的数据,对这些其它段也滚动内容,

我的要求是每一段点击表格视图,第一个单元格设置为top每次

我试着用setScrollToTopsetPagingEnable,但没有用,

[contactsTable setPagingEnabled:YES]; 
[contactsTable setScrollToTop:YES]; 

如何设置表查看第一个单元格总是位于顶部点击段和视图出现时,无论以前的步骤滚动...?

回答

2

试试这个,

[contactsTable setContentOffset:CGPointZero]; 
+0

或者使用'[contactsTable setContentOffset:CGPointZero动画:NO];' – iDev

1

这应做到:

NSIndexPath *ip = [NSIndexPath indexPathForRow:0 inSection:0]; 
[contactsTable selectRowAtIndexPath:ip animated:YES scrollPosition:UITableViewRowAnimationTop]; 
1
[contactsTable scrollToRowAtIndexPath:[contactsTable indexPathForCell:cell] atScrollPosition:UITableViewScrollPositionTop animated:YES];