将表视图部分标题传递给另一个视图的导航栏标题

Passing on tableview section title to another view's navigation bar title

我有一个主视图 (view1),其中包含以下代码。当我点击一个部分中的一个单元格时,它会推送到另一个视图 (view2),我希望该 view2 的标题与我点击的 view1 的部分标题相同。

view1

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 30)];

    UIImageView *imageView = [[UIImageView alloc] initWithFrame:headerView.frame];
    imageView.image = [UIImage imageNamed:@"bg_blue.png"];
    [headerView addSubview:imageView];

    UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(10, 5, kScreenWidth, 20)];
    title.textColor = [UIColor whiteColor];
    CategoryListData *data = self.dataArray[section];
    title.text = data.categoryTitle;
    [headerView addSubview:title];

    return headerView;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    MainHeaderTableViewCell *tableCell = (MainHeaderTableViewCell *)collectionView.superview.superview;
    CategoryListData *data = self.dataArray[tableCell.index];
    CategoryDetailData *detailData = data.categoryList[indexPath.row];

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    View2 *vc = [storyboard instantiateViewControllerWithIdentifier:@"View2"];
    vc.detailData = detailData;
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}

view2

- (void)initNavigationTitle {
    [self setupNavigationTitle:self.detailData.title backButtonWithAnimated:YES]; // this line need to be replaced with section name from view1

}

我正尝试在视图 2 中做这样的事情

CategoryListData *data = self.dataArray[section];
title.text = data.categoryTitle;
[self setupNavigationTitle:title.text backButtonWithAnimated:YES];

但是如何将参数部分从 view1 传递到 view2?

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    MainHeaderTableViewCell *tableCell = (MainHeaderTableViewCell *)collectionView.superview.superview;
    CategoryListData *data = self.dataArray[tableCell.index];
    CategoryDetailData *detailData = data.categoryList[indexPath.row];

    NSString *sectionTitle = [self.dataArray[tableCell.index] categoryTitle];

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    View2 *vc = [storyboard instantiateViewControllerWithIdentifier:@"View2"];
    vc.detailData = detailData;
    vc.title = sectionTitle;
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}