Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UICollectionView项隐藏在视图下方_Ios_Objective C_Iphone - Fatal编程技术网

Ios UICollectionView项隐藏在视图下方

Ios UICollectionView项隐藏在视图下方,ios,objective-c,iphone,Ios,Objective C,Iphone,我创建了一个collectionView,其中显示了10个项目 在iPhone4“或

我创建了一个collectionView,其中显示了10个项目

在iPhone4“或<屏幕中,滚动1或2个项目后,现在确实会显示一些项目

与UIScrollView一样,我们设置contentSize以显示屏幕下方的内容。因此,我们可以滚动内容

但在UICollectionView中,它现在显示了iPhone4的最后一项(第10项)和iPhone3.5的最后两项(第9项和第10项)

我尝试为集合视图设置contentSize,但仍然没有成功

UITableView工作得非常完美,但我想要collectionView的弹性效果,所以使用它

CGRect frame = CGRectMake( 0, 64, self.view.frame.size.width, self.view.frame.size.height - 64 );

CNStretchyCollectionViewFlowLayout *layout = [ [ CNStretchyCollectionViewFlowLayout alloc ] init ];

UICollectionView* collectionView = [ [ UICollectionView alloc ] initWithFrame:frame collectionViewLayout:layout ];

[ layout setItemSize:CGSizeMake(collectionView.frame.size.width - 15, CELL_HEIGHT) ];

// Register the cell
[ collectionView registerClass:[ TKCollectionViewCell class ] forCellWithReuseIdentifier:CellIdentifier ];

[ collectionView setContentInset:layout.bufferedContentInsets ];


// Set the delegate for the collection view

[ collectionView setDelegate:self ];
[ collectionView setDataSource:self ];
[ collectionView setClipsToBounds:YES];


// Customize the appearance of the collection view
[ collectionView setBackgroundColor:LIGHT_GRAY_COLOR ];

[ collectionView setIndicatorStyle:UIScrollViewIndicatorStyleDefault ];

[ collectionView setAlwaysBounceVertical:YES ];

[ self.view addSubview:collectionView ];

您是否尝试为布局指定contensize。就像
布局.contentsize
?是否有任何更改?没有布局。contentsize不存在。CNStretchCollectionViewFlowLayout-(CGSize)collectionViewContentSize{CGSize contentsize=[super collectionViewContentSize];返回contentsize;}如果我在4英寸屏幕上缩小itemSize,我可以看到所有项目,但在3.5英寸屏幕上看不到。您尝试为布局设置上下文。就像
布局。contentsize
?有什么变化吗?没有布局。contentsize不存在。CNStretchCollectionViewFlowLayout-(CGSize)collectionViewContentSize中有一个方法{CGSize contentSize=[super collectionViewContentSize];return contentSize;}如果我在4英寸屏幕中减小itemSize,我可以看到所有项目,但在3.5英寸屏幕中看不到