Durgaprasad
Durgaprasad

Reputation: 1951

iphone- Push a view after poping earlier view

I have one view pushed on navigation. Now I do following on click of button.

    [self.navigationController popViewControllerAnimated:YES];
    FreeStuffViewController * freeStuffVC=[[FreeStuffViewController   alloc]initWithNibName:@"FreeStuffViewController" bundle:nil];
    [self.navigationController pushViewController:freeStuffVC animated:YES];
    [freeStuffVC release];

It only pops a view, but dint push new FreeStuffVc. Please help.

Upvotes: 0

Views: 59

Answers (2)

Vinayak Kini
Vinayak Kini

Reputation: 2919

this works fine. Check it

        UINavigationController *local = [[UINavigationController alloc]init];
        [local popViewControllerAnimated:NO];
        newView *nr=[[newView alloc]init];
        [self.navigationController pushViewController:nr animated:YES];

Upvotes: 0

OnkarK
OnkarK

Reputation: 3793

Try this:

FreeStuffViewController * freeStuffVC=[[FreeStuffViewController alloc] initWithNibName:@"FreeStuffViewController" bundle:nil];
    [self.navigationController pushViewController:freeStuffVC animated:YES];
NSMutableArray *viewArray = [[self.navigationController viewControllers] mutableCopy];
[viewArray removeObjectAtIndex:viewArray.count - 2];
self.navigationController.viewControllers = viewArray;

Upvotes: 2

Related Questions