Ber*_*ges 2 iphone scroll uitableview ios
我想获得UITableVIewCell相对于屏幕的位置,而不是相对于tableview.因此,如果我滚动tableview,位置会更新.
您应该使用两个步骤来实现此目的:
Run Code Online (Sandbox Code Playgroud)- (CGRect)rectForHeaderInSection:(NSInteger)section; - (CGRect)rectForFooterInSection:(NSInteger)section; - (CGRect)rectForRowAtIndexPath:(NSIndexPath *)indexPath;
2. 使用UITableView的convertRect方法将CGRect转换为表的容器视图.例如.要获取第一个标头的当前位置,您可以使用此代码:
CGRect rect = [mytable convertRect:[mytable rectForHeaderInSection:0] toView:[mytable superview]];
Run Code Online (Sandbox Code Playgroud)
如果您想要这些以上语音,您可能希望在UITableView的委托方法中包含此代码:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView_ {.....
Run Code Online (Sandbox Code Playgroud)
我使用类似技术完成的一个例子是github - 如何使表头行固定:
https://github.com/codedad/SO_Fixed_TableHeader_iOS
希望它能帮到你!
归档时间: |
|
查看次数: |
2321 次 |
最近记录: |