1

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.

Dmitriy
  • 1,852
  • 4
  • 15
  • 33

2 Answers2

1

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.

mg.
  • 11
  • 1
  • Found this one too. But it doesn't fit to my needs. I'm trying to create a class, that can handle undetermined number of rows and columns. – Dmitriy Sep 05 '11 at 08:17
1

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.
Dmitriy
  • 1,852
  • 4
  • 15
  • 33