Get height of UITableView without scroll bars

前端 未结 4 1583
野趣味
野趣味 2021-01-31 02:25

I need to get the full height of a UITableView (i.e. the height at which there would be nothing more to scroll). Is there any way to do this?

I\'ve tried

4条回答
  •  广开言路
    2021-01-31 03:06

    If a table view rows count changed and you indeed need to know the content size of table view incorporating the last changes, I didn't find that layoutIfNeeded method actually helps.

    After a little bit hacking, I get to know how to force table view recalculate its content size. In my case, it is enough to reset table view frame to get it working:

    - (CGSize)com_lohika_contentSize
    {
        CGRect theFrame = self.frame;
        self.frame = CGRectZero;
        self.frame = theFrame;
        [self layoutIfNeeded];
        return [self contentSize];
    } 
    

提交回复
热议问题