Illep
Illep

Reputation: 16851

iPhone Navigation button previous button - Beginner

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

Upvotes: 1

Views: 105

Answers (2)

chown
chown

Reputation: 52778

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];
}

Upvotes: 2

Beltalowda
Beltalowda

Reputation: 4678

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

Upvotes: 0

Related Questions