iPhone correct landscape window coordinates

前端 未结 5 1079
终归单人心
终归单人心 2021-02-15 15:31

I am trying to get the window coordinates of a table view using the following code:

[self.tableView.superview convertRect:self.tableView.frame toView:nil]

5条回答
  •  广开言路
    2021-02-15 15:53

    This is a hack, but it works for me:

    UIView *toView = [UIApplication sharedApplication].keyWindow.rootViewController.view;
    [self.tableView convertRect:self.tableView.bounds toView:toView];
    

    I am not sure this is the best solution. It may not work reliably if your root view controller doesn't support the same orientations as the current view controller.

提交回复
热议问题