How to get indexpath in prepareForSegue

前端 未结 4 1036
予麋鹿
予麋鹿 2020-12-04 22:02
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
    {
    if ([segue.identifier isEqualToString:@\"Action\"])
    {
        NSIndexPath *indexP         


        
4条回答
  •  半阙折子戏
    2020-12-04 22:33

    sorry, i don't understand what you want to do. it's possible get the indexPath.row through this method of UITAbleViewDelegate that it's called when you tap the cell of your tableView:

    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{     
        self.myVariable = indexPath.row
    }
    

    and then you can access to this value in the prepareForSegue in this way:

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
        //do something with self.myVariable
    }
    

    I hope i helped you.

提交回复
热议问题