Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get the absolute position of a section header in tableview?

how to get the absolute position of a section header in tableview?

I have already used the tableView:viewForHeaderInSection: to get the header's view.But now i need to get the absolute position of this view in the screen. the return value's frame is not the absolute position in the screen.I also tried to call superview,but it seems not work.

like image 292
billbai Avatar asked Jul 28 '13 05:07

billbai


1 Answers

tableView:viewForHeaderInSection: is a UITableViewDelegate method for creating a header view for display. This means, however, that the view has not been added to the view hierarchy, rendering it's frame meaningless for your purposes.

Try

UIView *headerView = [tableView headerViewForSection:sectionIndex];

instead. From there you can try the following methods on the returned view to get the rect of the view in any other view's coordinate system:

[headerView convertRect:[headerView bounds] toView:[headerView window]];
like image 68
BergQuester Avatar answered Nov 11 '22 00:11

BergQuester