У меня есть основной вид (view1) с этим ниже кодом. Когда я нажимаю ячейку в секции, она будет нажимать на другое представление (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
}
Я пытаюсь сделать что-то подобное в View2
CategoryListData *data = self.dataArray[section];
title.text = data.categoryTitle;
[self setupNavigationTitle:title.text backButtonWithAnimated:YES];
Но как я могу передать раздел параметров из view1 в view2?
Можете ли вы показать код, как вы нажимаете view2. –
@ New16 ok Я только что обновил вопрос – SanitLee
Итак, у вас используется просмотр коллекции в ячейке tableview? – ashmi123