Search code examples
iphoneuitableviewuinavigationcontrollerpushviewcontroller

How push back view when click on row of table view?


I want to set an event that when we select any row then open a new view similarly when user click on row then user go back to first view. For example user have button in main view when click on that button then open a table view. When user click on any row then navigation controller push view to back to main view not in forward view. How implement this event in my project?


Solution

  • In table view delegate didSelectRowAtIndexPath use -

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    {
        [self.navigationController popViewControllerAnimated:TRUE];
    }