Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom layout UITableViewHeaderFooterView

So I just tried subclassing UITableViewHeaderFooterView and aligning the labels the way I want by overriding -layoutSubviews.

When I call super and change a label's frame, however, the app appears to be stuck in an infinite -layoutSubviews loop.

My code looks like this:

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.textLabel.frame = CGRectMake(10.0, 10.0, 300.0, 40.0);
}

Any ideas on how to fix this?

like image 646
Christian Schnorr Avatar asked Aug 09 '13 09:08

Christian Schnorr


People also ask

What is Uitableviewheaderfooterview?

A reusable view that you place at the top or bottom of a table section to display additional information for that section.


1 Answers

It seems an attempt to modify the frame of backgroundView or contentView not only causes an infinite loop, it will ignore any values you set to their frames, rendering their existence fairly useless. I've reverted to using the backgroundView and contentView as dumb containers for my own custom subviews with their own background visuals and layout properties. :S

like image 183
epologee Avatar answered Sep 21 '22 18:09

epologee