Jump to content
11 posts in this topic

Recommended Posts

In my app I have 2 UIViewControllers and a UINavigationController set up. In the second view controller, I have a UITableView. I've set the view controller's view to the UITableView (well it's done automatically) and both the delegate and datasource are set to the view controller's class. The problem is that whenever I push from the first view controller to the second, the table view is not visible on the second view controller. How can I fix this?

Well for starters, you don't want to rely on IB for this kind of stuff.

 

Make a new class that subclasses UITableViewController. It will automatically set itself as data source and delegate. Then, you take the methods from the view controller (the ones you used because it was delegate and data source), and put them into the UITableViewController class. (You do have methods like numberOfRowsInSecton, etc, right?). Then, in the other view controller class (the 1st VC), you have a void action called like push, then when invoked, calls the command to push the table view controller onto the navigation controller

 

[self.navigationController pushViewController:<the instance you created of your table view> animated:YES];

 

You have to make sure to import the table view controller class into the 1st view controller.

 

Hope this helps :rolleyes:

Well for starters, you don't want to rely on IB for this kind of stuff.

 

Make a new class that subclasses UITableViewController. It will automatically set itself as data source and delegate. Then, you take the methods from the view controller (the ones you used because it was delegate and data source), and put them into the UITableViewController class. (You do have methods like numberOfRowsInSecton, etc, right?). Then, in the other view controller class (the 1st VC), you have a void action called like push, then when invoked, calls the command to push the table view controller onto the navigation controller

 

[self.navigationController pushViewController:<the instance you created of your table view> animated:YES];

 

You have to make sure to import the table view controller class into the 1st view controller.

 

Hope this helps :)

 

Thanks I'll try this out. I really don't get what was wrong in IB tho, I had set the view controller's view to the table view, etc...I did the same with the view controller that is already included in the template I'm using and It worked.

Yeah, it should work, but I have had problems with this as well. With the iPhone SDK, I try to use IB less and less, because it seems to have some issues.

 

Thank you soooo much!!! It worked YAY! lol I've been trying to get this to work in IB for like 3 days now, so thank you very much!

×
×
  • Create New...