views:

435

answers:

1

Hey everyone. I am trying to incorporate a simple UINavigationController into my tab bar application. I have the TabBar set as the root controller and all seems to work fine. This method is called correctly and does not break yet it does not change to my detail view. I am completely lost on this one.

I followed instructions from this video: http://www.youtube.com/watch?v=LBnPfAtswgw&feature=player%5Fembedded#. I changed some things around to make it work with what I am trying to accomplish but the underlying logic I left the same. She is working with SDK 2.* and I am using 3.*. I assume this has something to do with it. Can anyone help me out? This is what my didSelectRowAtIndexPath looks like :

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic may go here. Create and push another view controller.
 NSInteger row = [indexPath row];
 if(self.detailViewController == nil) {
  LogEntryDetailViewController *logEntryDetail = [[LogEntryDetailViewController alloc]
              initWithNibName:@"LogEntryDetailView" bundle:[NSBundle mainBundle]];
  self.detailViewController = logEntryDetail;
  [logEntryDetail release];
 }

 detailViewController.title = [NSString stringWithFormat:@"%@", [logEntriesArray objectAtIndex:row]];

 ProgNameAppDelegate *delegate = (ProgNameAppDelegate *)[[UIApplication sharedApplication] delegate];
 [delegate.logViewNavController pushViewController:self.detailViewController animated:YES];
}

I am going nuts here. If I need to post this somewhere else I will be happy to do so. Thanks in advance!

+1  A: 

You should change these lines:

ProgNameAppDelegate *delegate = (ProgNameAppDelegate *)[[UIApplication sharedApplication] delegate];
[delegate.logViewNavController pushViewController:self.detailViewController animated:YES];

with this:

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

If you have a tab bar controller as you say, then pushing your detailViewController on delegate.logViewNavController is probably the wrong thing to do (depending on what delegate.logViewNavController is..., but since this is not working for you, my bet is that's where your confusion is).

In general, you don't need to complicate your code with accessing the application delegate to fetch a controller like that. All you need to do is push your new controller on self.navigationController in most practical cases.

Zoran Simic
I replaced these lines and now receive this "error: request for member 'logViewNavController' in something not a structure or union.This is why I was calling the delegate. Any more ideas? Thanks again!
Trent
I take that back. I didn't type your suggested code correctly. It works now! Thanks so much!
Trent