views:

43

answers:

2

Hi All,

I have a problem that I had working in a test but now in a bigger application I can't seem to sort out.

First of I have a view that has six button each loads a different view I am using:

- (IBAction)showInfo2:(id)sender {
InfoViewController *Infocontroller = [[[InfoViewController alloc] initWithNibName:@"InfoView" bundle:nil] autorelease];
Infocontroller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:Infocontroller animated:YES];
}

This seems to be working fine, and loads the next section, in this case 'infoview'. I then load a tableview and fill it full f data from an xml feed, this again is now working, (although was not an easy task for me!).

The problem comes when I know try and use: Nothing seems to happen, ie, the new view is not loaded.

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

// Navigation logic may go here -- for example, create and push another view controller.
SubInfoViewController *subInfoViewController = [[SubInfoViewController alloc] initWithNibName:@"SubInfoView" bundle:nil];
[self.navigationController pushViewController:subInfoViewController animated:YES];
[subInfoViewController release]; 
}

I know its being called because this works:

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

NSString *message = [[NSString alloc] initWithFormat:@"You selected a row"];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Row Selected" message:message delegate:nil cancelButtonTitle:@"Yes I did" otherButtonTitles:nil];
[alert show];

[message release];
[alert release];
}

Any help more than welcome, and please be gentle newbie :)

A: 

What exactly is the problem? Your code looks fine at first glance.

Chris Eidhof
Sorry, its the pushview controller that just doesn't seem to load the new view.
jimbo
+1  A: 

You're view is probably push into navigation stack but you can't see it because your parent view is modal.

You can't try to display your SubInfoViewController like this :

SubInfoViewController *subcontroller=[[SubInfoViewController alloc] initWithNibName:@"SubInfoViewController" withBundle:nil];
[self presentModalViewController:subcontroller animated:YES];
[subcontroller release];

If you want to keep a navigation logic in your app, you should not display your InfoViewController modally but present it in a common way in your navigation stack.

You can try to dismiss your modal view before pushing your SubViewController. In this case you must do something like this :

SubInfoViewController *controller=[[SubInfoViewController alloc] initWithNibName:@"SubInfoViewController" bundle:nil];
[self.parentViewController pushViewController:controller animated:YES];
[self dismissModalViewControllerAnimated:YES];
[controller release];

You'll receive a warning because parentViewController may not respond to pushViewController: animated: but with a NSLog you'll see that your parentViewController is actually a UINavigationController.

Hope this helps !

Ermiar