【发布时间】:2014-10-16 06:46:56
【问题描述】:
在纵向模式下,收藏视图看起来不错。但是当它是横向模式时,单元格不会重新排列......它们保持在同一个地方。
我添加了自动布局,以便集合视图伸展以填满屏幕,并且集合视图具有恒定的高度约束。
我的视图层次结构是这样的
View ->ScrollView->ContentView |--> 有问题的集合视图(通知标签上方的一个) | |-> Tableview(在通知标签之后) | |->集合视图(顶部的黑色空间)
集合视图的代码是
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;}
-(NSInteger)collectionView:(UICollectionView *)collectionView
numberOfItemsInSection:(NSInteger)section
{
return 14;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
if (collectionView==self.offerCollectionView) {
sliderCollectionInHomeScreen *myCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuseIdForSlider"
forIndexPath:indexPath];
myCell.labelForShopName.text = [[self.arrayForOfferSlider objectAtIndex:indexPath.row] objectForKey:@"shop_name"];
myCell.labelForOfferName.text = [[self.arrayForOfferSlider objectAtIndex:indexPath.row] objectForKey:@"offer_title"];
myCell.offerImage.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[[self.arrayForOfferSlider objectAtIndex:indexPath.row] objectForKey:@"img_url"]]]];
;
return myCell;
}
【问题讨论】:
-
分享一些代码,它是否给出任何错误或警告?
-
它没有显示任何错误。
-
分享一些收藏视图的代码。
标签: ios objective-c uicollectionview uicollectionviewlayout