私はカスタム 'UICollectionViewCell'の内部にtableViewを作成しています。私のViewControllerの中には、各行にTableViewで表示されるデータを含む配列があります。 したがって、この配列のデータをカスタムセル(tableview delegatesメソッドを含む)に渡したいと思います。ViewController内の配列データをUICollectionViewカスタムセルに渡す方法は?
私はこのようにしていますが、それは助けにはなりません。
インサイド "GroupCollectionViewCell.m"
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *groupTableIdentifier = @"DeptGroupTable";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:groupTableIdentifier];
if (cell == nil) {
}
RoadmapViewController *vc = [[RoadmapViewController alloc] init];
cell.textLabel.text =[vc.grouplist objectAtIndex:indexPath.row];
return cell;
}
そして内部 "RoadViewController.m"
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
GroupCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
if (cell == nil) {
cell = [[GroupCollectionViewCell alloc] init];
// [cell.groupData addObjectsFromArray:_grouplist];
//:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
return cell;
}
注 - ここで、groupListもし私が渡す配列とgroupDataはカスタムセル内の空の配列です。
すべては大丈夫ですが、私はしないでください。
そして "
なぜ私は "cell"から "loadTableData"メソッドを取得できないのか知っています。 –RoadViewController.m
" は、このメソッドを追加で申し訳ありません。このメソッドを 'CollectionViewCell.h'ファイルで宣言する必要があるのを忘れてしまいました。その方法を宣言すれば、それが利用可能になります。 –
私はすでに宣言しています。私はcell.loadTableData(arr)は動作しないと思う。私は他の方法で使用する必要があります。 –