Hi Beth,

Something that you might try, just to simplify the number of IB hookups and cut down on the possibility of errors there, is to change this line:

[delegate.topicsTableNavController pushViewController:questionDetail animated:YES];

To just:

[self.navigationController pushViewController:questionDetail animated:YES];

The UIViewController class has a method (-navigationController) to access the navigation controller that it is currently inside of. Using it will keep you from having to look up you app delegate, since it looks like the problem that you are having is that your app delegate's "topicsTableNavController" outlet is not getting set.

Hope this helps,
        - Greg

On Jun 15, 2009, at 8:26 AM, Beth Freeman wrote:

Hello,This is a follow up question to my previous question about combining a
navigation controller with a tab bar controller.

I have successfully combined the two in building the interface with
Interface Builder: My top level controller is a tab bar controller. This
references a navigation controller, which references a table view
controller. Selecting a row from the table view is then supposed to display a UI view (ie, not another table view). When I run the program, I see the tab bar, the navigation bar and the table with my data just fine. However,
when I select a row from the table, I never see the UI view.

In my accessoryButtonTappedForRowWithIndexPath method (see below) in my table view controller, my navigation controller appears to be null. When I put a breakpoint at the line when I push the view controller on the stack,
the address of the navigation controller is 0x0.

I have studied TheElements example from Apple extensively and believe I am
doing everything correctly in IB.  Since TheElements example is built
programmatically, it's a little difficult for me to know if I've done
everything I need to do to hook things up correctly, but I believe I have. My understanding is that when I drag a controller from the library into my MainWindow.xib window, I'm "instantiating" that as an object. I have an
object in my MainWindow.xib window whose class is set to
TopicsTableNavController (the navigation controller for the first tab), however, as described above, this appears to not be instantiated at the
breakpoint.

In TheElements example, the navigation controllers are created and added to the tab bar view controllers programmatically. My assumption was that when you assign the view controllers for the tab bar controller through IB, and set the class of each of the view controllers through IB, I'm instantiating
the objects at that time.

Am I missing something? Is there something I need to do programmatically to set up the navigation controller that I don't know about? Am I wrong about
how IB works?

In the code below, I set up the view controller for the view that should be pushed onto the stack (questionDetail) and, I assume, displayed. I do see the log message just before the push, and have verified that my view is being set up correctly. However, the view is never displayed, I'm guessing
because the navigation controller is 0x0 and is thus nil.

Thanks so much in advance for any help.

Elisabeth



- (void)tableView:(UITableView *)tableView
accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {

NSUInteger row = [indexPath row];

if (self.questionDetail == nil) {

QuestionDetail *aQuestionDetail = [[QuestionDetail alloc] initWithNibName:
@"QuestionDetail" bundle:nil];

self.questionDetail = aQuestionDetail;

[aQuestionDetail release];

}

questionDetail.title = [NSString stringWithFormat:@"Question from %@",
[topicsArray objectAtIndex:row]];

if (QADetail != nil) {

[questionDetail.question setText:[QADetail objectForKey:@"question"]];

[questionDetail.answer setText:[QADetail objectForKey:@"answer"]];

}

NDQAppDelegate *delegate = [[UIApplication sharedApplication] delegate];

NSLog(@"Pushing Question Detail View Controller");

[delegate.topicsTableNavController pushViewController:questionDetail
animated:YES];

}
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/greg%40omnigroup.com

This email sent to g...@omnigroup.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to