Ios7 UICollectionView没有';渲染不好

Ios7 UICollectionView没有';渲染不好,ios7,Ios7,该程序有一个tableview。每个TableViewCell都有一个UICollectionView。当用户拖放其中一个类别标签时,程序将添加一个UICollectionViewCell,其中包含一个UIView。它工作得很好。但是,当用户滚动tableview时,UICollectionView将无法正确渲染。显示如下 这是用户滚动视图之前的图片。 用户滚动视图后,会出现一个重叠的sin。承诺牢房不应该在那里。 这是我的CellForRowatineXpath代码 - (UITableV

该程序有一个tableview。每个
TableViewCell
都有一个
UICollectionView
。当用户拖放其中一个类别标签时,程序将添加一个
UICollectionViewCell
,其中包含一个
UIView
。它工作得很好。但是,当用户滚动tableview时,
UICollectionView
将无法正确渲染。显示如下

这是用户滚动视图之前的图片。

用户滚动视图后,会出现一个重叠的sin。承诺牢房不应该在那里。

这是我的CellForRowatineXpath代码

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";

// Configure the cell..
/*
 There is no UITableViewCell in the storyboard
 */
ContentViewCustomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

UILabel * cellLabel = nil;  //The cellLabel is for rendering the bible verses

if (cell==nil) {
    cell = [[ContentViewCustomTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

    /*
     To Make Dynamic Cell Height
     */
    cellLabel = [[UILabel alloc] initWithFrame:CGRectZero];
    [cellLabel setNumberOfLines:0];
    [cellLabel sizeToFit];

    [cellLabel setFont:[UIFont systemFontOfSize:FONT_SIZE]];
    [cellLabel setTag:1];
    [[cell contentView] addSubview:cellLabel];
}

NSString * text = [verseArray objectAtIndex:[indexPath row]];
CGSize constraint = CGSizeMake(CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), 20000.0f);
CGRect rectangular = [text boundingRectWithSize:constraint options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:FONT_SIZE]} context:nil];
CGSize size = rectangular.size;

/*
 When There Are Rows More Than One Screen
 */
if (!cellLabel) {
    cellLabel = (UILabel *)[cell viewWithTag:1];
}
cell.CellContent = text;
[cellLabel setText:text];
[cellLabel setFrame:CGRectMake((self.view.frame.size.width*0.39), 0, CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), MAX(size.height, 44.0f))]; //To Locate The Position Of The Label In The Cell

cell.userInteractionEnabled = TRUE;
return cell;
}
这是ContentViewCustomTableViewCell

#import "ContentViewCustomTableViewCell.h"
#import "AnswerCollectionViewCell.h"

@implementation ContentViewCustomTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
    // Initialization code

    UICollectionViewFlowLayout * layout = [[UICollectionViewFlowLayout alloc] init];
    layout.sectionInset = UIEdgeInsetsMake(3, 3, 2, 2);
    layout.itemSize = CGSizeMake(30, 10);
    layout.scrollDirection = UICollectionViewScrollDirectionVertical;
    self.collectionView = [[AFIndexedCollectionView alloc] initWithFrame:CGRectZero
                                                    collectionViewLayout:layout];

    [self.collectionView registerClass:[AnswerCollectionViewCell class]forCellWithReuseIdentifier:CollectionViewCellIdentifier];

    self.collectionView.backgroundColor = [UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:0.1];
    self.collectionView.showsVerticalScrollIndicator = NO;

    [self.contentView addSubview:self.collectionView];

}
return self;
}

- (void)awakeFromNib
{

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];

// Configure the view for the selected state
}

-(void)layoutSubviews
{
[super layoutSubviews];
self.collectionView.frame = CGRectMake(10, 10, 110, 50);
}

-(void)setCollectionViewDataSourceDelegate:(id<UICollectionViewDataSource,      UICollectionViewDelegate>)dataSourceDelegate index:(NSInteger)index
{
self.collectionView.dataSource = dataSourceDelegate;
self.collectionView.delegate = dataSourceDelegate;
self.collectionView.index = index;

[self.collectionView reloadData];
}


@end
#导入“ContentViewCustomTableViewCell.h”
#导入“AnswerCollectionViewCell.h”
@实现ContentViewCustomTableViewCell
-(id)initWithStyle:(UITableViewCellStyle)样式重用标识符:(NSString*)重用标识符
{
self=[super-initWithStyle:style-reuseIdentifier:reuseIdentifier];
如果(自我){
//初始化代码
UICollectionViewFlowLayout*布局=[[UICollectionViewFlowLayout alloc]init];
layout.sectionInset=UIEdgeInsetsMake(3,3,2,2);
layout.itemSize=CGSizeMake(30,10);
layout.scrollDirection=UICollectionViewScrollDirectionVertical;
self.collectionView=[[AFIndexedCollectionView alloc]initWithFrame:CGRectZero
collectionViewLayout:布局];
[self.collectionView注册表类:[AnswerCollectionViewCell类]forCellWithReuseIdentifier:CollectionViewCellIdentifier];
self.collectionView.backgroundColor=[uicolorWithred:0.1绿色:0.1蓝色:0.1 alpha:0.1];
self.collectionView.showsVerticalScrollIndicator=否;
[self.contentView addSubview:self.collectionView];
}
回归自我;
}
-(无效)从NIB中唤醒
{
}
-(无效)设置选定:(BOOL)选定动画:(BOOL)动画
{
[超级设置选定:选定动画:动画];
//为所选状态配置视图
}
-(无效)布局子视图
{
[超级布局子视图];
self.collectionView.frame=CGRectMake(10,10,110,50);
}
-(void)setCollectionViewDataSourceDelegate:(id)dataSourceDelegate索引:(NSInteger)索引
{
self.collectionView.dataSource=dataSourceDelegate;
self.collectionView.delegate=dataSourceDelegate;
self.collectionView.index=索引;
[self.collectionView-reloadData];
}
@结束

尝试此链接:您好,我想上传一张图片,帮助我解释问题所在。但我的名声是1。如何分享我的屏幕截图?谢谢。你可以通过点击上方{}旁边的图标来添加屏幕截图。谢谢iDeveloper,我的意思是我知道如何添加屏幕截图。但是,由于缺乏声誉,我不能添加屏幕截图。我对你的问题投了赞成票。再投票一次,你就可以发布一张照片了。在任何情况下,根据我的经验,这是由于没有正确重置单元格内容造成的。我不记得我是否没有清除模型或者我是否没有正确地将单元格出列。你能把CellForRowAtIndexPath贴出来吗?