UITableViewCell包含一个带有UICollectionView的自定义视图

时间:2015-06-14 14:32:24

标签: ios objective-c uitableview multidimensional-array uicollectionview

我有一个带有xib的CUSTOMVIEW,视图中包含UICollectionView。 然后我在UITableViewCell中的UIViewController内添加自定义视图。 从那个UiviewController我创建一个不同长度的数组数组来填充UICollectionViewCell。但我没有得到理想的结果。 UITableView在第三个数组后重复3个第一个数组,这是UIViewControllers viewDidLoad中的数组样本:

array1= [NSArray arrayWithObjects:zeroItem, seventhItem, nil];
array2= [NSArray arrayWithObjects:thirdItem,forthItem,nil];
array3= [NSArray arrayWithObjects:fifthItem,sixthItem, nil];
array4= [NSArray arrayWithObjects:eighthItem,seventhItem, nil];
array5= [NSArray arrayWithObjects:forthItem,zeroItem, nil];

我在惰性实例化中填充主数组:

-(NSMutableArray *)arrayStack
{
    if (!_arrayStack) {
        _arrayStack = [[NSMutableArray alloc] init];

        [_arrayStack addObject:array1];
         [_arrayStack addObject:array2];
         [_arrayStack addObject:array3];
         [_arrayStack addObject:array4];
         [_arrayStack addObject:array5];        
    }
    return _arrayStack;
}

这是UITableView的dataSource,其中我用数组填充UICollectionViewCell

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return [self.arrayStack count];
}

- (FFStackCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    FFStackCell * cell = [tableView dequeueReusableCellWithIdentifier:@"FFStackCell" forIndexPath:indexPath];

    cell.THECUSTOMVIEW.stackOfVideos = self.arrayStack[indexPath.row];
    cell.theTitle.text = [NSString stringWithFormat:@"Stack %ld",(long)indexPath.row+1];

    return cell;
}

这里的问题是在array3之后,数组重复自身,并且不会出现array4和array5。 我是否混合了UITableView中的UIViewControllerUICollectionView CUSTOMVIEW的代表。 所以请给我一些建议。 提前谢谢。

0 个答案:

没有答案