Illep
Illep

Reputation: 16851

How to navigate back to the previous view

When the user clicks on a row in a TableViewController. I want select the content of that view and the user should navigate back to the previous screen.

How can i do this.

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    // How to navigate back to the previous view ?

}

Please note that this is a Navigation Controller based application.

Upvotes: 0

Views: 284

Answers (3)

serhat sezer
serhat sezer

Reputation: 1334

[self.navigationController popToViewController:[YOUR ViewContoller]] animated:YES];

This is the best way to return specific view controller. If you have more than one view controller you should for-in loop and catch your viewcontroller and assing it to [YOUR Viewcontroller] place.

Upvotes: 1

Zakaria Wahabi
Zakaria Wahabi

Reputation: 213

try this :

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    [self.navigationController popViewControllerAnimated:YES];

}

Upvotes: 0

Robin
Robin

Reputation: 87

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:`(NSIndexPath *)indexPath {`
[self.navigationController popToRootViewControllerAnimated:YES];
}

Upvotes: 1

Related Questions