★ TouchArcade needs your help. Click here to support us on Patreon.

Table View inside another view?

08-12-2009, 02:47 PM
#1
Joined: Apr 2009
Location: London, UK
Posts: 317
Send a message via ICQ to cramzy Send a message via Skype™ to cramzy
Table View inside another view?

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
08-12-2009, 03:17 PM
#2
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>

--- ChronoSoft ---
Support your roguelikes! Play Rogue Touch today!
Spirit Hunter Mineko: Demons Reach --- Work in progress! Follow us on Twitter!
08-12-2009, 03:19 PM
#3
Joined: Apr 2009
Location: London, UK
Posts: 317
Send a message via ICQ to cramzy Send a message via Skype™ to cramzy
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
08-12-2009, 03:26 PM
#4
Quote:
Originally Posted by cramzy View Post
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
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

--- ChronoSoft ---
Support your roguelikes! Play Rogue Touch today!
Spirit Hunter Mineko: Demons Reach --- Work in progress! Follow us on Twitter!
08-12-2009, 03:53 PM
#5
Joined: Apr 2009
Location: London, UK
Posts: 317
Send a message via ICQ to cramzy Send a message via Skype™ to cramzy
Hey, it works!!!!
You're the man!!!!

Thanks a lot!!!

Cheers,
ILIYA