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

前端 未结 9 1299
梦如初夏
梦如初夏 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:17

        - (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
              switch (indexPath.row) {
        case "X"
            // Allocate the viewController 
            [navigationcontroller.pushViewController:"yourviewcontroller" animated:YES];
            [release "yourviewcontroller"];
            break;
    
        default:
            break;
    }
    }
    

    EDIT: Didn't realize of what you're trying. As shani said, you should not create a viewcontroller for each row if there is no need to. Try changing the datasource for each row but using the same viewcontroller. So forget this implementation.

提交回复
热议问题