Table View inside another view?

Discussion in 'Public Game Developers Forum' started by cramzy, Aug 12, 2009.

  1. cramzy

    cramzy Well-Known Member

    Hi guys,

    I need to put a table view inside another view. I've been trying for a couple of hours now, but no success.

    In one hand, I have my view with its view controller. On the other hand I have a table view in this first view, but how do I link it with a table view controller? My view controller cannot act as view controller and table view controller at the same time, so I think I need two controllers, but I am not sure...

    Any idea?

    Cheers,
    ILIYA
     
  2. CommanderData

    CommanderData Well-Known Member
    Patreon Indie

    When you say trying to put a tableview inside another view, you mean with Interface Builder, or via code? Using IB I have no idea (hate that blasted thing and write all my views in code only), but you should be able to add a tableview as a subview to an existing view. No need for the tableviewcontroller really, just make sure the tableview is it's own <UITableViewDataSource, UITableViewDelegate>
     
  3. cramzy

    cramzy Well-Known Member

    Hi!

    I've been making some mix between code and IB actually... probably this is the problem, but who knows.

    Anyway, if I go the way you said- how do I provide custom cell UI and table data? I mean, so far I have all these methods in the Table View Controller...now, where do they go?
    Or you mean that the view that holds the table view, should implement the two delegates?

    Cheers,
    ILIYA
     
  4. CommanderData

    CommanderData Well-Known Member
    Patreon Indie

    Well, I'd put all those methods in the containing view, and make it the source and delagate. When initializing the containing view- alloc a new UITableView with the position and size you desire, set .datasource and .delegate = self (the containing view), then add this new UITableView as a subview.

    I know it works, because I do that in Rogue Touch to handle the inventory/pack screen :D
     
  5. cramzy

    cramzy Well-Known Member

    Hey, it works!!!! :)
    You're the man!!!!

    Thanks a lot!!!

    Cheers,
    ILIYA
     

Share This Page