Re: UITableView's tableFooterView and autolayout
Re: UITableView's tableFooterView and autolayout
- Subject: Re: UITableView's tableFooterView and autolayout
- From: Sebastian Celis <email@hidden>
- Date: Wed, 11 Jun 2014 08:56:12 -0500
Hi Torsten,
On Jun 11, 2014, at 6:26 AM, Torsten Curdt <email@hidden> wrote:
> So what's the story with tableFooterView and tableHeaderView and
> autolayout? I am trying to put a label into a footer.
I have had luck with code like the following:
- (void)viewDidLoad
{
[super viewDidLoad];
self.headerView = [[MyView alloc] initWithFrame:CGRectZero];
}
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
CGRect frame = CGRectZero;
frame.size.width = self.tableView.bounds.size.width;
frame.size.height = [self.headerView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
if (self.tableView.tableHeaderView != self.headerView || !CGRectEqualToRect(frame, self.headerView.frame))
{
self.headerView.frame = frame;
[self.headerView layoutIfNeeded];
self.tableView.tableHeaderView = self.headerView;
}
}
- Sebastian
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden