Ajit
Ajit

Reputation: 964

drawing grids in a UITableViewCell using Monotouch

Hi I am just a week old with Monotouch, the task that I have in hand is to display a table on an ipad with multiple rows and multiple columns i.e. a grid like structure with many cells and each cell containing some data which can later be edited too. My application should look somewhat like the figure below, except that it has to be working on an ipad.

My application should look somewhat like this, except that it is to be working on an ipad

The only useful link I've found is this, but this article discusses how to do so using Objective C(now since I am using Monotouch & c# so I am not comfortable with Objective C so I cannot understand this solution).

So my question how to achieve the same (i.e. a table with many columns and rows - a grid) using Monotouch.

Please help! Thanks in Advance.

Upvotes: 2

Views: 1093

Answers (1)

miguel.de.icaza
miguel.de.icaza

Reputation: 32694

Ajit,

If you want to use the UITableView'to render your data, you should effectively make it so that each "row" can render the columns in the way that you need.

What you need to do is to create a UIView subclass that can render the elements in your columns. There are various ways of doing that, you can:

  • Create your own UIView that implements a draw method and draws on demand.
  • Create a UIView that is a composite and merely has some children views

Once you have the view, you can add this to your UITableViewCell

You can follow some of my recommendations for creating those UITableViewCells here:

http://tirania.org/monomac/archive/2011/Jan-18.html

But 2-D browsing using a 1-D design is not optimal. Chances are that all that you want is to render your various items in a grid, so you might as well just use the UIScrollView directly and add all of your child UIViews there.

The only difference is that UITableView is designed to recycle/reuse some expensive objects (each row) while a basic design that stashes everything on the view will not have any of those benefits.

A more advanced option would be for you to create/destroys the views that are shown/hidden as the user scrolls.

Upvotes: 3

Related Questions