1

I need to implement the back button; (as in webpages, when you click the back button the screen will set focus to the previous screen).

I am not using a navigation control here, instead i want to do this using a Navigation bar and then adding a navigation button on it. Now when the user clicks on the navigation button the previous view should be displayed.

How should i do this.

My screen looks like this :

When i click on Hello, it should go to the previous screen. enter image description here

Illep
  • 16,375
  • 46
  • 171
  • 302

2 Answers2

2

Check out UINavigationController Class Regerence then try something like this:

- (void)pickerCancel {
    [self dismissModalViewControllerAnimated:YES];
}

- (void)doSomething {
    [myView.navigationItem setBackBarButtonItem:[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(pickerCancel)] autorelease]];
    UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:myView];
    [navigation setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
    [navigation setDelegate:self];
    [self presentModalViewController:navigation animated:YES];
    [myView release];
    [navigation release];
}
chown
  • 51,908
  • 16
  • 134
  • 170
0

You really should use a UINavigationController as that is its entire purpose.

Beltalowda
  • 4,558
  • 2
  • 25
  • 33