iOS 7 Custom TableView Is Under TabBar

后端 未结 16 1675
萌比男神i
萌比男神i 2020-12-13 04:31

Im trying port my app to iOS7, but my custom TableViewController is showing the last row (cell) under the TabBar :(

Im searchi

16条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-13 05:09

    I had the same problem, and the up-voted answers did not solve it. See my answer to a similar question, Tab Bar covers TableView cells in iOS7.

    I solved the issue by manually setting the table view's frame in the table view controller's viewWillAppear: method to the height of the screen - (status bar height + nav bar height + tab bar height).

    - (void)viewWillAppear:(BOOL)animated
    {
        [super viewWillAppear:animated];
    
        // Adjust height of tableview (does not resize correctly in iOS 7)
        CGRect tableViewFrame = self.tableView.frame;
        tableViewFrame.size.height = [self heightForTableView];
        self.tableView.frame = tableViewFrame;
    }
    
    - (CGFloat)heightForTableView
    {
        return CGRectGetHeight([[UIScreen mainScreen] bounds]) -
               (CGRectGetHeight([[UIApplication sharedApplication] statusBarFrame]) +
                CGRectGetHeight(self.navigationController.navigationBar.frame) +
                CGRectGetHeight(self.tabBarController.tabBar.frame));
    }
    

    If anyone finds a better solution to this problem, please share!

提交回复
热议问题