How can I move to another view controller when the user clicks on a row?

前端 未结 9 1318
梦如初夏
梦如初夏 2020-12-21 17:41

I am new to iPhone development, and I want to move to another page when the user clicks on a particular row. So, if they click on first row, I want the page to redirect to t

9条回答
  •  不知归路
    2020-12-21 18:18

    It sounds like using a UINavigationController is what you want.

    You then push your "first view" on to the navigation controller's stack from the table view, e.g., from you UITableView delegate:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        ...
    
        // indexPath.row == 0
        FirstViewController* firstVC = [[FirstViewController alloc] initWithNibName...];
        [self.navigationController firstVC animated:YES];
        [firstVC release];
    
        ...
    }
    

提交回复
热议问题