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.
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]];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With