小编jan*_*nne的帖子

尝试(并失败)在UITableView下更改颜色

我有一个UITableView,显示在UINavigationController中.我正在尝试更改表格下方视图的颜色,这样当您向下拉桌子时,您会看到除白色之外的其他内容.

我试过这两个:

self.tableView.backgroundView.backgroundColor = [UIColor blackColor];
self.navigationController.view.backgroundColor = [UIColor blackColor];
Run Code Online (Sandbox Code Playgroud)

分开和一起.仍然看到白色.

我错过了什么?

view background-color uitableview uinavigationcontroller

3
推荐指数
1
解决办法
665
查看次数

尝试将节页脚添加到UICollectionView时崩溃

我正在尝试将一个页脚添加到UICollectionView并以我不理解的方式失败.

我正在设置这样的主单元格:

[collectionView registerClass:[PickerOpenCell class] forCellWithReuseIdentifier:cellIdentifier];
UINib *cellNib = [UINib nibWithNibName:@"PickerOpenCell" bundle:nil];
[collectionView registerNib:cellNib forCellWithReuseIdentifier:cellIdentifier];

UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
flowLayout.itemSize = CGSizeMake(130, 50);

[collectionView setCollectionViewLayout:flowLayout];
Run Code Online (Sandbox Code Playgroud)

xib是UICollectionViewCell的子类,只包含一个UILabel.一切正常.

现在我想添加节页脚,所以我添加它(与上面的代码交错,所以setCollectionViewLayout调用仍然是序列中的最后一个):

[collectionView registerClass:[PickerOpenFooter class] forCellWithReuseIdentifier:footerIdentifier];

UINib *footerNib = [UINib nibWithNibName:@"PickerOpenFooter" bundle:nil];
[collectionView registerNib:footerNib forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:footerIdentifier];

flowLayout.footerReferenceSize = CGSizeMake(130, 2);
Run Code Online (Sandbox Code Playgroud)

这次的xib是UICollectionReusableView的子类,并包含一个视图(它的意思是各部分之间的水平白线).视图的大小为130 x 2.

我添加footerReferenceSize行的那一刻,应用程序在setCollectionViewLayoutLine上崩溃了

由于未捕获的异常'NSRangeException'终止应用程序,原因:' - [__ NSArrayM objectAtIndex:]:索引0超出空数组的边界'

我不知道这可能是哪个数组,谷歌没有提供任何帮助.有任何想法吗?我一定忘了把事情搞砸了,但我找不到.

ios uicollectionview uicollectionviewlayout

1
推荐指数
1
解决办法
1285
查看次数