views:

37

answers:

4

Hello again,

So I am trying to simple traverse to the next level of a table view by doing this:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 1) {
        FiltersController *aFiltersCont = [[FiltersController alloc] init];
        aFiltersCont.displayedFilters = [appDelegate.groupedBusiness allKeys];
        aFiltersCont.currentLevel = self.currentLevel + 1;
        [self.navigationController pushViewController:self animated:YES];
    }
}

is there any reason why this would not be pushing the controller? I had a similar problem before, but solved it by displaying the view modally. However, this time, this is in a popover and needs to slide to the next screen inside that popover. Any Ideas? Thanks in advance.

OK I am going to put some more source up here to try and help...

Inside the main view controller I have this code to make the popover from a button:

   // Create and configure the filters controller.
FiltersController *aFiltersController = [[FiltersController alloc] initWithStyle:UITableViewStylePlain];
 self.filtersController = aFiltersController;
filtersController.appDelegate = self.appDelegate;



UINavigationController *filtersNavController = [[UINavigationController alloc] initWithRootViewController:filtersController];


UIPopoverController *filtersPopover = [[UIPopoverController alloc]     initWithContentViewController:filtersNavController];
self.filtersPopoverController = filtersPopover;
filtersPopoverController.delegate = self;

and then I have the code I first posted in my filtersController class. Does that help at all?

A: 

you are pushing self which is a reference to the current view controller. you should change the line with the push to the following if aFiltersCont is the viewController you are trying to drill to.

[self.navigationController pushViewController:aFiltersCont animated:YES]; 
Jesse Naugher
+1  A: 
[self.navigationController pushViewController:self animated:YES];

Should be

[self.navigationController pushViewController:aFiltersCont animated:YES];
jtbandes
Yeah, I actually caught that right after I posted this. It was not the problem, do you have any other ideas?
gabaum10
@gabaum10: Check that `self.navigationController` is not nil, and that `aFiltersCont` isn't nil.
jtbandes
They are not nil.
gabaum10
A: 

You might be confused about the index. The first index is 0 not 1, so maybe you want indexPath.row == 0?

Also, you should release aFiltersCont before returning (you're leaking a FiltersController and anything it owns every time you run this method.

So maybe this?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 0) {
        FiltersController *aFiltersCont = [[[FiltersController alloc] init] autorelease];
        aFiltersCont.displayedFilters = [appDelegate.groupedBusiness allKeys];
        aFiltersCont.currentLevel = self.currentLevel + 1;
        [self.navigationController pushViewController:aFiltersCont animated:YES];
    }
}
Andrew Pouliot
Well the row doesn't really matter at this point. That is something that will make a bigger difference once the view is pushing. That is exactly what I have right now.
gabaum10
A: 

If you are just displaying your sublcass of UITableViewController inside a UIPopoverController, the UINavigationController will not be created for you automatically. You may need to modify the code where you are creating the UIPopoverController with something like this:

MyTableViewController *table = [[[MYTableViewController alloc] init] autorelease];
UINavigationController *nav = [[[UINavigationController alloc] initWithRootViewController:table] autorelease];
myPopover = [[UIPopoverController alloc] initWithContentViewController:nav];

Then you should be able to push and pop navigation controllers on the stack no problem.

Joe Ibanez
Well I am creating a navigation controller, which is why this is so confusing. Following all the logic I have seen, what I have should work. I am really at a loss...
gabaum10