所以我一直在Xcode4中为一个有多个集合视图的应用程序工作(准确地说是4)
我有两个视图,一个底部的"主"视图,其中包含一个填充屏幕的大型集合视图,以及一个较小的"抽屉"视图,可以从侧面拉出并包含三个窄的,水平滚动的集合视图,一个堆叠在一起另一个的顶部.
我一直使用标签和cellforitematpath方法中的if语句来填充单元格.在xcode 4中,以及我在xcode 4中创建的项目,我现在在xcode 5中打开,这是有效的.我在底部得到一个警告(而不是错误)control may reach end of non void function,但我仍然可以构建和运行它的工作原理.
在xcode 5中的一个新项目中,相同的代码将"控制可能达到非空函数的结尾"视为错误,并且不允许构建和运行.这无穷无尽令人沮丧.除非有一个数组要填充单元格,否则我不想返回单元格.我甚至都不知道'返回零'是什么意思.有没有人有任何关于如何关闭它的建议?
以下绝对不是很好,请自担风险:
- (UICollectionViewCell *) collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
if (collectionView.tag == 0){
static NSString *CellIdentifier = @"subjectCell";
SubjectCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
AHSubject *cellSubject = [self.subjectsArray objectAtIndex:indexPath.row];
[[cell subjectLabel]setText:cellSubject.name];
return cell;
}
else if (collectionView.tag == 1){
if ([categoryArray count] > 0) {
static NSString *CellIdentifier = @"categoryCell";
CategoryCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
AHCategory *cellCategory = [categoryArray objectAtIndex:indexPath.row]; …Run Code Online (Sandbox Code Playgroud)