How to resize a tableHeaderView of a UITableView?

后端 未结 19 2241
死守一世寂寞
死守一世寂寞 2020-11-29 16:14

I\'m having trouble resizing a tableHeaderView. It simple doesn\'t work.

1) Create a UITableView and UIView (100 x 320 px);

2) Set the UIView as tableHeaderV

19条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-29 17:02

    Obviously, by now Apple should have implemented UITableViewAutomaticDimension for tableHeaderView & tableFooterView...

    The following seems to work for me using layout contraint(s):

    CGSize   s  = [ self  systemLayoutSizeFittingSize : UILayoutFittingCompressedSize ];
    CGRect   f  = [ self  frame ];
    
    f.size   = s;
    
    [ self  setFrame : f ];
    

提交回复
热议问题