テザリング中などでステータスバーが高くなったときにコンテンツがずれる

iPhoneでテザリング中などのときにステータスバーの高さが倍(20→40pt)になります。そのときにscrollViewのInsets.topを20pt増加させると、なぜかコンテンツが下に20ptずれてしまいます。これは、ステータスバーの高さが20pt増加した分、rootViewControllerのframe.origin.yが0→20ptに変化しているためです。この問題に対応するには、scrollViewのInsets.topからrootViewController.view.frame.origin.yを引くことで対処できます。


    theDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    UIEdgeInsets inset = self.tableView.contentInset;

    float statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.height;
    float navigationBarHeight = self.navigationController.navigationBar.frame.size.height;
    float tabBarHeight = self.tabBarController.tabBar.frame.size.height;
    float rootviewTop = theDelegate.window.rootViewController.view.frame.origin.y;

    self.tableView.contentInset = UIEdgeInsetsMake(statusBarHeight + navigationBarHeight - rootviewTop, inset.left, tabBarHeight, inset.right);