Change view when tableview cell is pressed?

前端 未结 1 1169
情深已故
情深已故 2021-01-29 06:34

i need help. When my tableView\'s cell is selected, i want the cell to go to a page of its own, i don\'t want every cell to go to the same page. I tried using :

         


        
1条回答
  •  离开以前
    2021-01-29 06:49

    First off, albertamg's answer points out an important concept; the presentModalViewController should be called on self.

    Second, it sounds like you need to have something unique happen in each subsequent view that you present, presumably based on data that creates your table cell. One way to do this is to set a @property on your FirstFolderViewController, just before you present it, and then when it's viewWillAppear function, is called, you can act on that value.

    For example,

    FirstFolderViewController * first = [[FirstFolderViewController alloc]init];
    first.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    
    first.folderNumber = indexPath.row; // Added
    
    [self presentModalViewController:first animated:YES];
    [first release];
    

    ...assuming you're calling this inside your - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath method, and you've set up a property called folderNumber inside your FirstFolderViewController.

    0 讨论(0)
提交回复
热议问题