1
employeeDetailed  = [[[EmployeeDetailedViewController alloc] initWithNibName:@"EmployeeDetailedViewController" bundle:nil] autorelease];
    UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:employeeDetailed] autorelease];
    [employeeDetailed release];
    [self.navigationController pushViewController:navController animated:YES];

I try this its saying bad access.[crash]

how to reslove this issue.

@ thanks in advance

4 Answers 4

2
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    // Override point for customization after application launch.
    // Set the view controller as the window's root view controller and display.
    UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:self.viewController] autorelease];
    self.window.rootViewController = navController;
    [self.window makeKeyAndVisible];

    return YES;
}



employeeDetailed  = [[[EmployeeDetailedViewController alloc] initWithNibName:@"EmployeeDetailedViewController" bundle:nil] autorelease];

[self. navigationController presentModalViewController: navController];

This will work for you try this.

Sign up to request clarification or add additional context in comments.

Comments

1

You have autorelease set in the first line (alloc/init)

You are then explicitly releasing the view controller on line three.

You are therefore over-releasing this object and causing the crash.

You can remove the [employeeDetailed release] line and it will be fine.

4 Comments

@thanks IanL forget memory issue.! can you help me out how to pushViewController its not pushing for me
As beryllium mentioned, you cannot push a new UINavigationController onto an existing navigation stack. You refer to self.navigationController, so I assume that the current controller is part of a stack. In which case you should be able to simply use: [self.navigationController pushViewController:employeeDetailed animated:YES];
yeap i used [self.navigationController pushViewController:employeeDetailed animated:YES]; still the controller is not doing any thing!
does self.navigationController exist? i.e. Are you sure that the current controller is part of a navigation stack?
0

You cannot add UINavigationController to existed navigation stack. Instead of you need to show new navigation controller modal like this:

employeeDetailed  = [[[EmployeeDetailedViewController alloc] initWithNibName:@"EmployeeDetailedViewController" bundle:nil] autorelease];
UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:employeeDetailed] autorelease];
[self presentModalViewController: navController];

2 Comments

i do not want presentmodalviewcontroller sir. I need the pushViewController
then push only employeeDetailed, without navController.
0

The Best Way I found to present Navigation Controller in a specific part in your Application is like these:

MyViewController *myViewController = [[MyViewController alloc]initwithnibname :@"MyViewController"];
    UINavigationController *myNavC = [[UINavigationController alloc]initWithRootViewController:myViewController];

Then in your myViewController.m use

[self.NavigationController pushViewController: XController animated:YES]; 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.