Grouped UITableView with vertical gridlines

1k Views Asked by At

I'm trying to create UITableView with vertical gridlines, using method described here: http://www.iphonedevx.com/?p=153 . Everything works fine, until I switch table style to grouped.

Vertical lines just don't appear on the table, though overridden drawRect: is still called.

What am I doing wrong? Is there some major difference between cells for grouped and plain UITableView? Is it possible at all to draw primitives on the cells for grouped tables?

Thanks in advance.

PS: I'm using XCode 4, iOS SDK 4.3 and running the project with iPhone 4.3 simulator.

2

There are 2 best solutions below

0
Dmitriy On BEST ANSWER

OK, I've found a solution myself.

  • I've subclassed UILabel, which represents a single cell in a grid. Override of drawRect: draws path with rounded corners and fills it with desired color. Background color of a label is set to clear color, otherwise no rounded corners for me.
  • Then I've subclassed a UITableViewCell that adds labels to itself. To simulate margins it adds offsets to labels' frame.origin.x and frame.origin.y.
  • All this stuff contained in a plain UITableView, but with margins and rounded corners it looks like a grouped one.
1
mg. On

Just looking for the same. Found this guy's blog. It looks promising. He uses a custom png with the grid to complete the effect.