Newbie advice

Discussion in 'iOS Programming' started by batfink-dan, May 16, 2009.

  1. batfink-dan macrumors newbie

    May 16, 2009
    Hi, I am currently playing around writing little apps via the various online tutorials and 'Learning iPhone Development'. My question is, how can I display a table of data with multiple columns and an undefined number of rows?

    If I knew the number of rows, I guess I could take the somewhat tedious route of using a load of labels or text fields.

    If I only wanted a single column of data I can see how I could use the Table View Controller.

    I can also see how I could use multiple table views next to each other, but if I did that then the rows wouldn't stay aligned when I scrolled down.

    There's probably a really simple answer to this, but would anyone mind enlightening me? :confused:

  2. dejo Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    I'd like more elaboration on what you mean by "undefined number of rows" but you can do a varying amount of rows using a UITableView. Then you can either subclass a UITableViewCell or just populate the contentView of a cell with subviews to achieve the multiple columns. Hope that helps.
  3. batfink-dan thread starter macrumors newbie

    May 16, 2009
    Aye-aye - that sounds like a solution. I actually meant a user-defined number of rows, so 'undefined' as in 'I don't know, but the user would', but that would preclude the use of several text fields or labels adjacent to each other.

    Thanks for the pointer.
  4. johnnyjibbs macrumors 68030


    Sep 18, 2003
    London, UK
    Table views are flexible so you can add more rows or take some away as necessary while your app is running.
  5. veo321 macrumors regular


    May 12, 2009
  6. drivefast macrumors regular

    Mar 13, 2008
    as for going multiple columns across, unless your columns are relatively narrow, you may soon run out of real estate. the table view is only designed for a single column, and you can have sections for a better classification, but any more than 1 column you will need to come up with your own design. i would probably try multiple, narrow table views in a UIScrollView, or a single UIScrollView that can scroll both horizontally and vertically. hmm, and if i think better, it may be easier to go directly for the 2nd alternative. this is not an application that i would recommend to beginners though, as it takes a good deal of experience with the standard classes.
  7. batfink-dan thread starter macrumors newbie

    May 16, 2009
    Um, I needed to read that a couple of times to make sense of it, so I think it's currently beyond me! For info, I have a table view and have forced landscape orientation, as it simply wouldn't fit into a portrait view. Thanks for the help.

Share This Page