views:

104

answers:

3

hello i am having same issue, i tried your solution but it didnt help me in my case.. i am not getting exception but view is not getting changed..

my piece of code is as below

printf("hi");
//Get the selected country
NSString *selectedCountry = [listOfItems objectAtIndex:indexPath.row];
//Initialize the detail view controller and display it.
DetailViewController *aSecondView = [[DetailViewController alloc]  initWithNibName:@"DetailView" bundle:nil];
// aSecondView.selectedCountry = selectedCountry;
[self.navigationController pushViewController:aSecondView];
[aSecondView release];
aSecondView = nil;
printf("bye..");

both hi and bye gets printed but view doesnt change.. i have wasted 2 days around it .. plz help me out..

A: 

Check the nib name.How did you created the nib file for the detail view?.It will be created by default as DetailViewController in your case.So change the initWithNibName.Why do you set the aSecondView=nil?

as kovpas said , that subclass your controller from UIViewController instead of UINavigationController ,you use presentModalViewController. for implementing navigation controller put this code in your delegate class

- (void)applicationDidFinishLaunching:(UIApplication *)application {    
UINavigationController *nvcontrol =[[UINavigationController alloc] initWithRootViewController:viewController];

[window addSubview:nvcontrol.view];

[window makeKeyAndVisible];

}
Warrior
A: 

in case if you un comment your commented code...one another problem that i found in your code... interchange these 2 lines...

aSecondView.selectedCountry = selectedCountry;
[self.navigationController pushViewController:aSecondView];

try Put it like this

 [self.navigationController pushViewController:aSecondView];
  aSecondView.selectedCountry = selectedCountry;

if you uncommnet the line it may create problem

mihirpmehta
aSecondView.selectedCountry = selectedCountry; this given as a comment line.whats there in changing the comment line?
Warrior
oh... Code hasn't been put inside Code tag... so it's hard to read... i haven't noticed it... but if in case it will uncomment... it may cause a problem... Thanks for pointing that out...
mihirpmehta
ok thanks..............
org.life.java
+1  A: 

Seems, that you subclass your controller from UIViewController instead of UINavigationController

Try to use

[self presentModalViewController:aSecondView animated:YES];

Dismiss it with

[self dismissModalViewControllerAnimated:YES];
kovpas
Where did you get that assumption from? There is nothing to suggest in the code that there is any subclassing of a `UINavigationController`. All `UIViewController` s have a `navigationController` property which points to the parent navigation controller of the view controller if one exists. The problem is more likely to be that either the instantiation of the view controller isn't working because of a Nib Name error, or that there is no parent navigation controller...
Jasarien
Jasarien,Just got same error two days ago :). Subclassing from UINavigationController worked, as well as presentModalViewController.
kovpas
Thankssssssssssssss it worked.,..
org.life.java