iOS本页跳本页(在不知道有几个子页面的情况下)

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    NSDictionary *dic = [[NSDictionary alloc]init];

    if (self.globleArray.count > 0) {

        dic = self.globleArray[indexPath.row];

    } else {

        dic = self.tempArray[indexPath.row];

    }

    

    if ([dic objectForKey:@"children"] != nil) {

        NSMutableDictionary *tempDic = [[NSMutableDictionary alloc]init];

        [tempDic setObject:[dic objectForKey:@"children"] forKey:[dic objectForKey:@"id"]];

        BranchViewController *branch = [[BranchViewController alloc]init];

        branch.globleArray = [dic objectForKey:@"children"];

        [self.navigationController pushViewController:branch animated:YES];

    } else {

        

   NSNotification *noti = [[NSNotification alloc]initWithName:@"branch" object:self.branchArray[indexPath.row] userInfo:nil];

        [[NSNotificationCenter defaultCenter] postNotification:noti];

        for (UIViewController *controller in self.navigationController.viewControllers) {

            if ([controller isKindOfClass:[ChooseBranchViewController class]]) {

                ChooseBranchViewController *messageVC =(ChooseBranchViewController *)controller;

                [self.navigationController popToViewController:messageVC animated:YES];

            }else{

            }

        }

    }

}

猜你喜欢

转载自blog.csdn.net/kkxmforever/article/details/80929594