Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to return a nil CGFloat?

I'd like to return nil to tableView:heightForFooterInSection: but that's not allowed. Is there a way to return nil as a CGFloat?

Why are you doing this?
I'm testing how a tableView will behave with a mix of Titles and Views as sectionFooters. For one footer I need to use a custom view, but for another footer I have 3 or 4 sentences of text and I like how the system styles it and sizes the footer to fit. But as soon as I implement heightForFooterInSection (which is required by viewForFooterInSection), the footer with the title no longer auto-resizes to fit the given text. I'm trying to avoid building a custom view for the straight text.

like image 405
Andrew Avatar asked Feb 22 '12 20:02

Andrew


1 Answers

There's no such thing as nil for primitive values. You could try returning 0.0f, but I don't know how UITableView responds to that. It may just hide the view entirely. Presumably if you want to return a custom view for one footer, you need to return a custom view for all footers.

like image 183
Lily Ballard Avatar answered Oct 06 '22 10:10

Lily Ballard