[iPhone] (newbie) navigation controller is null, combining navigation controller and tab bar controller
[iPhone] (newbie) navigation controller is null, combining navigation controller and tab bar controller
- Subject: [iPhone] (newbie) navigation controller is null, combining navigation controller and tab bar controller
- From: Beth Freeman <email@hidden>
- Date: Mon, 15 Jun 2009 08:26:26 -0700
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 (email@hidden)
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:
This email sent to email@hidden