Question

I'm trying to add a way for my app to display data in an easily comprehensible form. I tried doing this with graphs, but found it to be a bit awkward, so I'm off to find a better solution.

Here's a problem: I want to show up to 30 days of data, with user reported events plotted against a timeline. The events should align vertically, to visually provide a reference of when certain events cluster together.

To solve the problem, I thought of using a UITableView with a background which has a scale, and superimpose upon that background a set of "pins", indicating user events. As the table is scrolled, the events would align one under another, providing a good indication historic event development: Custom UITableViewCell with pins indicating user events

I know that this is possible to be done with a UIScrollView, where I can just position a series of rulers and add events as pins. In order to do this efficiently, I'll have to use Tiling, a technique that I don't have much experience with.

I'm interested in knowing if this is possible with a UITableView, where caching and tiling is already done for me.

I tried adding UIImageViews to a tableViewCell.backgroundview , but this does not produce the desired results. I'd like to be able to dynamically add any number of subviews to the table cell. I can do this by adding a certain pre-determined number of images to an .xib and then trying to reposition them, but this does not seem like an ideal solution.

Is what I'm trying to do possible with UITableView, or should I abandon these efforts and look at UIScrollView with tiling?

Thank you!

Was it helpful?

Solution

yes this should be possible. Add the ruler image to the background of the UITableViewCell.

Then create a subclass of UITableViewCell that takes an array of pins objects that it will place within its view. The pin objects would contain the pin image and a horizontal location on the scale. Then in the tableView dataSource method cellForRowAtIndexPath method you set the tableViewCell's pin array to the correct array (or NSSet) of pins.

To make it even more lightweight, you could draw the pins yourself in the UITableViewCell subclasses drawRect method. Then you could just pass the locations of the pins.

Good luck

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top