Ilyace Posted August 3, 2008 Share Posted August 3, 2008 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? Link to comment https://www.insanelymac.com/forum/topic/119144-some-help-with-view-controllers-iphone-sdk/ Share on other sites More sharing options...
stroke Posted August 3, 2008 Share Posted August 3, 2008 I'm sorry — what is the point of pushing to the new view controller if the content will be the same? :s It changes views... the table view is part of the RootViewController, not your second one. Link to comment https://www.insanelymac.com/forum/topic/119144-some-help-with-view-controllers-iphone-sdk/#findComment-843755 Share on other sites More sharing options...
Ilyace Posted August 3, 2008 Author Share Posted August 3, 2008 Wait so there's no way I can make the table view on the second view controller? That's what I'm trying to do. Link to comment https://www.insanelymac.com/forum/topic/119144-some-help-with-view-controllers-iphone-sdk/#findComment-843767 Share on other sites More sharing options...
stroke Posted August 4, 2008 Share Posted August 4, 2008 Then go into Interface Builder and put a table on it. I'm not quite sure what you're trying to accomplish here. Link to comment https://www.insanelymac.com/forum/topic/119144-some-help-with-view-controllers-iphone-sdk/#findComment-844988 Share on other sites More sharing options...
alloutmacstoday Posted August 4, 2008 Share Posted August 4, 2008 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 Link to comment https://www.insanelymac.com/forum/topic/119144-some-help-with-view-controllers-iphone-sdk/#findComment-845027 Share on other sites More sharing options...
Ilyace Posted August 4, 2008 Author Share Posted August 4, 2008 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. Link to comment https://www.insanelymac.com/forum/topic/119144-some-help-with-view-controllers-iphone-sdk/#findComment-845173 Share on other sites More sharing options...
alloutmacstoday Posted August 4, 2008 Share Posted August 4, 2008 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. Link to comment https://www.insanelymac.com/forum/topic/119144-some-help-with-view-controllers-iphone-sdk/#findComment-845179 Share on other sites More sharing options...
Ilyace Posted August 4, 2008 Author Share Posted August 4, 2008 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! Link to comment https://www.insanelymac.com/forum/topic/119144-some-help-with-view-controllers-iphone-sdk/#findComment-845199 Share on other sites More sharing options...
alloutmacstoday Posted August 5, 2008 Share Posted August 5, 2008 your welcome glad I could help Link to comment https://www.insanelymac.com/forum/topic/119144-some-help-with-view-controllers-iphone-sdk/#findComment-845221 Share on other sites More sharing options...
stroke Posted August 5, 2008 Share Posted August 5, 2008 Using Interface Builder saved me about 1000 lines of code Link to comment https://www.insanelymac.com/forum/topic/119144-some-help-with-view-controllers-iphone-sdk/#findComment-845383 Share on other sites More sharing options...
alloutmacstoday Posted August 5, 2008 Share Posted August 5, 2008 IB does rock, but somethings don't like to work in it. It has saved me lots of time, sometimes though. So, I still love it Link to comment https://www.insanelymac.com/forum/topic/119144-some-help-with-view-controllers-iphone-sdk/#findComment-845916 Share on other sites More sharing options...
Recommended Posts