13

All --

I’ve just started using Eureka forms builder on an iOS project, and it has a lot of wonderful features. It’s very nicely done.

However, I eventually realized that there doesn’t seem to be a good way to customize the Height of any given row. [Interestingly, in the Example app, many different rows demonstrating different features are all the same height.]

Granted I can override heightForRowAtIndexPath (which I’ve tried) ... but rows (and indexes) get added dynamically when they’re hidden and unhidden, which makes things more complicated.

Before getting into even more workarounds for this: Is there a simpler / more elegant way of adjusting individual row heights within the framework itself?

I’d like to set the height of any given row within the definition of each Row, or its .cellSetup, .cellUpdate or similar closures.

enter image description here

Or even better, is there a straightforward way to have the UITableView respect the ‘intrinsic’ dimensions of only those labels which are used, according to the actual font sizes used? In other words, if the font in a given row is smaller, that row height should be correspondingly less.

Your help very much appreciated at this point.

Thank you in advance!

Reinier Melian
  • 20,519
  • 3
  • 38
  • 55
rondoagogo
  • 664
  • 6
  • 22

2 Answers2

36

try with this

 <<< TextRow().cellSetup({ (cell, row) in
                cell.height = ({return 10})
            })

this will change the height, I Hope this helps you

Reinier Melian
  • 20,519
  • 3
  • 38
  • 55
  • 1
    Thank you so much. It looks like this needs to happen under `.cellUpdate`, (rather than `.cellSetup`). But I never would have figured out the syntax without your help. I’m very appreciative. Thanks! – rondoagogo Dec 26 '16 at 22:27
  • @rondoagogo Is something wrong with the answer? can I help you? – Reinier Melian Dec 26 '16 at 23:12
  • No, your answer was very helpful! I’m just waiting to see if anyone has an idea about automatically respecting the ‘intrinsic’ dimensions first. – rondoagogo Dec 27 '16 at 04:01
  • 1
    Well the intrinsic dimensions are bounded to the type of cells defined by the framework, I think, if you need an specific cells you must create your own type of cells, with your own requirements. – Reinier Melian Dec 27 '16 at 14:23
  • Yes, that makes sense, thanks. Again, I appreciate your very helpful answers (and am awarding you the bounty). Thank you again very much! – rondoagogo Dec 28 '16 at 06:20
  • your answer work most of the time but height not being updated occasionally, how about that? – Hamed Nova Oct 06 '18 at 07:39
  • 1
    @nova within `.cellUpdate` call `row.reload()` – Leon Mak Dec 19 '18 at 10:23
  • @LeonMak you're a lifesaver! in my case calling `row.reload()` in `.cellUpdate` alongside with calling `$0.cell.height = { UITableView.automaticDimension }` into row's `init` closure makes it work – Alexander Saenko Sep 01 '20 at 22:25
0

Update the cell's height:

TextRow.cellUpdate { cell, row in
   cell.height = { 10 }
}
Community
  • 1
  • 1
shbedev
  • 1,875
  • 17
  • 28