I am trying to achieve a newsstand like effect with a scrolling and repeating background. I could do this using a UITableView if I could set it’s content size (An inherited method that seems to be overridden by something else in the UITableView Code) in order to fill the view with unscrollable cells.
Currently I am planning to make a custom uiscrollview. Which will be more complex and won’t have the cell reuse.
So, is there a way to set a UITableView’s content size.
You could semi-hack a ‘contentSize’ kind of control over a UITableView by simply setting the number of cells that you have (let’s assume you have a 1 section table view and aren’t using a ‘grouped’ styled table) to:
your desired height contentSize height / height for each cell (default is 44)
Now, your problem is that if you only have, say, three rows’ worth of data to display, what to do with the rest of the cells? Well, simply set their
backgroundColorto the same as the table’s background color and theirselectionStyleproperty toUITableViewCellSelectionStyleNone. Wham, now you have invisible cells, and can set the ‘contentSize’ of the table.Note that your contentSize will only have a resolution of the height of your cells, if you leave the cell heights at their default 44, then you can only set the contentSize to a multiple of 44.