tags:

views:

42

answers:

1

this is my flow navA-> navB->navC then when user press NavC back button he goes to navA

but when user again press navA he should go to navB but its going on navC i dont know why

in navC i did this

XMLAppDelegate *appDelegate=(XMLAppDelegate*)[UIApplication sharedApplication].delegate;
    [self.view removeFromSuperview];
    [appDelegate.window addSubview:appDelegate.preLoginNavController.view];

and in navA i am doing this to go to navB //this is preLoginNavController.m XMLAppDelegate appDelegate=(XMLAppDelegate)[UIApplication sharedApplication].delegate;

    //appDelegate.RootNavController.shouldHasBackButton = YES;
    [self.navigationController.view removeFromSuperview];
    [appDelegate.window addSubview:appDelegate.navigationController.view];//[navigationController view]

and in appdidfinish()

[window addSubview:[preLoginNavController view]];
    [window makeKeyAndVisible];**strong text**

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported' thats why i am using this a

appDelegate.newsNavController.shouldHasBackButton = YES;
 [appDelegate.window addSubview:appDelegate.newsNavController.view];

do i need to push in the mehtod defined bu you or i can use in betwwen while adding subview??

like

AccountApplication* controller = [[AccountApplication alloc] initWithNibName:@"AccountApplication" bundle:nil];
        //      [self.navigationController pushViewController:controller animated:YES];
        //      [controller release];
+2  A: 

Try to use the push/pop methods of UINavigationController:

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated

instad of adding and removing views from your app window

UPDATE:

You can create your own UINaviagtioNController in your appDelegate:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
// Override point for customization after app launch

UIViewController *rootViewController = [[UIViewController alloc]init];
navigationController = [[UINavigationController alloc]initWithRootViewController:rootViewController];
[rootViewController release];

[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
return YES;

}

with navigationController as @property.

Try to create a new "Navigation-based Application" or a "Tab Bat Application".

AlexVogel
check updates above
ram
if i push new then do i need to pop old one or just keep pushing whatevr i need????
ram
any pushed UIViewController is added to the stack and stays there unless you pop it or the hole stack.see Class reference:http://developer.apple.com/iphone/library/documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html
AlexVogel