以编程方式在 UITableViews viewForHeaderInSection 中添加一个 UICollectionView
Programatically add a UICollectionView in the UITableViews viewForHeaderInSection
如何以编程方式在 UITableView
的 viewForHeaderInSection
中添加 UICollectionView
?
-(UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UICollectionView *cell;
return cell;
}
注意:我已经在 .h
文件中添加了 UICollectionViewDataSource and UICollectionViewDelegate
。但是,我不确定如何以编程方式创建 UICollectionView
。有人可以帮忙吗
也许你想要 [[UICollectionView alloc] initWithFrame:(CGRect)];?
我不知道你的 class 设计,但也许你可以初始化集合视图并在 viewdidload 中设置它们的委托和数据源,将它们存储在数组中,然后选择集合视图viewForHeaderInSection 中的正确索引。
如何以编程方式在 UITableView
的 viewForHeaderInSection
中添加 UICollectionView
?
-(UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UICollectionView *cell;
return cell;
}
注意:我已经在 .h
文件中添加了 UICollectionViewDataSource and UICollectionViewDelegate
。但是,我不确定如何以编程方式创建 UICollectionView
。有人可以帮忙吗
也许你想要 [[UICollectionView alloc] initWithFrame:(CGRect)];?
我不知道你的 class 设计,但也许你可以初始化集合视图并在 viewdidload 中设置它们的委托和数据源,将它们存储在数组中,然后选择集合视图viewForHeaderInSection 中的正确索引。