Kri*_*hna 8 objective-c uitableview ios
我在表视图中有20行,并且我在屏幕的一半(使用IB)设计(或说调整大小)UITableView,在半屏幕中我显示与特定UITableViewCell相关的内容.将在半屏幕中显示哪个单元格的详细信息是运行时间.我希望在加载第二个最后一个单元格的视图时可以看到单元格.
我怎样才能做到这一点?
Nic*_*kel 18
我发现确保整个单元格可见的最简单方法是让tableview确保单元格的rect是可见的:
[tableView scrollRectToVisible:[tableView rectForRowAtIndexPath:indexPath] animated:YES];
Run Code Online (Sandbox Code Playgroud)
测试它的一种简单方法就是将其放入-(void)tableView:didSelectRowAtIndexPath:- 如果它被部分隐藏,则点击任何单元格然后将其滚动到位.
小智 12
UITableView 课程提供:
-(void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath
atScrollPosition:(UITableViewScrollPosition)scrollPosition
animated:(BOOL)animated;
Run Code Online (Sandbox Code Playgroud)
这似乎是你在寻找什么.
该NSIndexPath对象可以使用内置:
+(NSIndexPath *)indexPathForRow:(NSInteger)row inSection:(NSInteger)section;
Run Code Online (Sandbox Code Playgroud)
尝试scrollToRowAtIndexPath:atScrollPosition:animated ::
NSUInteger indexArray[] = {1,15};
NSIndexPath *indexPath = [NSIndexPath indexPathWithIndexes:indexArr length:2];
[yourTableView scrollToRowAtIndexPath:indexPath atScrollPosition: UITableViewScrollPositionTop animated:YES];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7767 次 |
| 最近记录: |