ios - How to dynamically calculate height of UITableViewCell according to device -


i have uitableviewcontroller now, , have x cells uitableview, same height screen. don't want scroll uitableview, , want divide whole screen x parts same height.

do have check device type first, calculate height of every cell? there lots of if or switch statement. best way achieve this?

thanks.

assume have navigation bar, try this:

func tableview(tableview: uitableview, heightforrowatindexpath indexpath: nsindexpath) -> cgfloat {     let screenheight = uiscreen.mainscreen().bounds.height     return (screenheight - 64) / <number of cells> } 

if don't have nagivation bar, replace

return (screenheight - 64) / <number of cells>

with

return screenheight / <number of cells>


Comments