Note that there are some explanatory texts on larger screens.

plurals
  1. POTab Bar and Nav Controller: Where did I go wrong in my Interface Builder wiring?
    primarykey
    data
    text
    <p>I've been working on an iPhone application in XCode and Interface Builder of the Tab Bar project type. After getting a table view of topics (business sectors) working fine I realized that I would need to add a Navigation Control to allow the user to drill into a subtopics (subsectors) table.</p> <p>As a green Objective-C developer, that was confusing, but I managed to get it working by reading various documentation trying out a few different IB options. My current setup is a Tab Bar Controller with Tab 1 as a Navigation Controller and Tab 2 a plain view with a Table View placed into it. The wiring works: I can log when table rows are selected and I'm ready to push a new View Controller onto the stack so that I can display the subtopics Table View. </p> <p>My problem: For some reason the first tab's Table View is a delegate and dataSource of the second tab. It doesn't make sense to me and I can't figure out why that's the only setup that works. I am having other problems that I believe are caused by the goofy wiring.</p> <p><a href="http://i43.tinypic.com/30nap85.jpg" rel="nofollow noreferrer">alt text http://i43.tinypic.com/30nap85.jpg</a></p> <p>Here is the wiring:</p> <ul> <li>Navigation Controller (Sectors) is a delegate of Tab Bar <ul> <li>Navigation Bar is a delegate of Navigation Controller (Sectors)</li> <li>View Contoller (Sectors) has a view of Table View </li> <li>Table View (in Navigation Controller (Sectors)) is a delegate of First View Controller (Companies)</li> <li>Table View (in Navigation Controller (Sectors)) is a dataSource outlet of First View Controller (Companies)</li> </ul></li> <li>First View Controller (Companies) <ul> <li>First View Contoller (Sectors) has a view of Table View </li> <li>Table View (in First View Controller (Companies)) is not hooked up to a dataSource outlet and is not a delegate</li> </ul></li> </ul> <p>When I click the tab buttons and look at the Inspector I see that the first tab is correctly hooked up to my MainWindow.xib and the second tab has selected a nib called SecondView.xib. It's in the File's Owner of MainWindow.xib where I inherit UITableViewDataSource and UITableViewDelegate (and also UITabBarControllerDelegate) in the .h, and in the .m where I implement the delegate methods. </p> <p>Why does this setup only work when the Table View in my first tab (View Controller (Sectors)) is a delegate and dataSource of the second tab? I'm confused: why wouldn't it need to be hooked up to the Navigation Controller-enabled tab in which the Table View is seen (Navigation Controller (Sectors))? The Table View seen on the second tab has neither dataSource and is not a delegate.</p> <p><a href="http://i40.tinypic.com/15ri1ig.jpg" rel="nofollow noreferrer">alt text http://i40.tinypic.com/15ri1ig.jpg</a> <a href="http://i44.tinypic.com/2dwete9.jpg" rel="nofollow noreferrer">alt text http://i44.tinypic.com/2dwete9.jpg</a></p> <p>I'm having trouble getting a pushViewController to fire (self.navigationController is not nil but the new View Controller still doesn't load) and I suspect that I need to work out this IB wiring issue before I can troubleshoot why the Nav Controller won't push a new View Controller onto the stack. </p> <pre><code>if(nil == self.navigationController) { NSLog(@"self.navigationController is nil."); } else { NSLog(@"self.navigationController is not nil."); SectorList *subsectorViewController = [[SectorList alloc] initWithNibName:@"SectorList" bundle:nil]; subsectorViewController.title = @"Subsectors"; [[self navigationController] pushViewController:subsectorViewController animated:YES]; [subsectorViewController release]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload