Tag: uicollectionview

向左或向右滑动以加载具有集合视图单元格高亮显示的视图控制器

我有3个视图控制器称为firstvc, secondvc, thirdvc 。 我有一个水平滚动的集合视图。 如果我select我的first cell我的firstvc在我的子视图显示在我的mainviewcontroller 。 它同样也是2, 3rd cell 。 没关系 。 现在我需要一个function,如果我滑动我的subview ,将有我所有的视图控制器时,我select任何单元格。 我需要添加左右滑动。 例如 : 如果我在firstvc那么我的first cell将被选中 。 现在,如果我滑动我的subview ,我的secondvc必须来意味着,而我的第二个集合视图单元格也必须highlight 我不知道如何涂抹。 我的代码: @IBOutlet weak var collectionview: UICollectionView! @IBOutlet weak var contentSubView: UIView! func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return self.items.count } // make a cell for each […]

收集视图单元格中的文本设置出错

当我设置它nslog值后它是NULL,任何一个词为什么? CustomCollectionVIewCell *cell =[[CustomCollectionVIewCell alloc]init]; NSString *name =[dict valueForKey:@"filterName"];//works [cell.labelDisplay setText:name];//does not NSLog(@"name = %@",cell.labelDisplay.text); cell.isSelected=NO; [_availableHealthFilters setObject:cell atIndexedSubscript:i];

多个UICollectionView在一个控制器中

我有一个视图与两个UICollectionViews设置。 每个视图都有一个以不同大小支持的数组。 collection1由array1支持,而collection2由array2支持。 问题是,从numberOfItemsInSection返回collection1的数量正被应用于两个集合视图。 例如,如果array1的大小为4,array2的大小为5,那么这两个集合将显示4个元素。 如果array1的大小是5,array2的大小是4,那么当我滚动collection2的时候,它会调用cellForItemAtIndexPath,其collectionIndex为5,我得到一个NSRangeException。 我怎样才能使每个collectionView使用它自己的大小? – (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section; { if(view == self.colleciton1){ return self.array1.count; } else if (view == self.collection2){ return self.array2.count; } return 0; } – (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath; { if(cv == self.collection1){ CharacterCell *cell = [cv dequeueReusableCellWithReuseIdentifier:FIRST_CELL_IDENTIFIER forIndexPath:indexPath]; cell.label.text = self.array1[indexPath.item]; return cell; } else if (cv == […]

警告:UICollectionViewFlowLayoutcaching了索引path'abc'的帧不匹配

这是导致警告的代码: private override func layoutAttributesForItemAtIndexPath(indexPath: NSIndexPath) -> UICollectionViewLayoutAttributes? { let attributes = super.layoutAttributesForItemAtIndexPath(indexPath) let distance = CGRectGetMidX(attributes!.frame) – self.midX; var transform = CATransform3DIdentity; transform = CATransform3DTranslate(transform, -distance, 0, -self.width); attributes!.transform3D = CATransform3DIdentity; return attributes } 控制台还打印: 这可能是因为stream布局“xyz”正在修改由UICollectionViewFlowLayout返回的属性而不复制它们。 我如何解决这个警告?

获取button操作:UICollectionView单元格

我用nib创build了一个UICollectionViewCell ,并在其中添加了一个button,并创build了一个.h和.m文件,将这个类添加到了nibs file's owner中。然后在.m中写入一个button动作,通过插口连接它。 收集视图填充正常,但无法触发button操作。 我认为收集单元的代表被调用。 我怎样才能得到button的动作?

UICollectionView装饰视图

有没有人实现了iOS 6 UICollectionView的装饰视图? 在网上实现装饰视图是不可能的。 基本上在我的应用程序,我有多个部分,我只是想显示每个部分后面的装饰视图。 这应该很容易实现,但我没有运气。 这使我疯狂…谢谢。

UICollectionView registerClass:forCellWithReuseIdentifier方法中断UICollectionView

什么是registerClass:forCellWithReuseIdentifier:的作用registerClass:forCellWithReuseIdentifier:方法? 根据苹果的开发者文件,它应该是 “注册一个类用于创build新的集合视图单元格”。 当我尝试使用它时,我的项目收到黑色的collections视图。 当我删除它一切工作正常。 #define cellId @"cellId" #import "ViewController.h" #import "Cell.h" @interface ViewController () @property (weak, nonatomic) IBOutlet UICollectionView *collectionView; @property(strong, nonatomic)NSMutableArray * photoArray; @end @implementation ViewController – (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. NSLog(@"%@",_photoArray); _photoArray = [[NSMutableArray alloc]initWithCapacity:0]; [_collectionView registerClass:[Cell class] forCellWithReuseIdentifier:cellId]; […]

UICollectionView插入上面维护位置的单元格(如Messages.app)

默认情况下,Collection View在插入单元格时保持内容偏移。 另一方面,我想插入单元格上方的当前显示的,以便他们出现在屏幕上方边缘像Messages.app当加载早期的消息。 有没有人知道如何实现它?

uicollectionview删除顶部填充

我有一个UICollectionView是整个视图,但它住在“视图”(它不是UICollectionViewController)。 向这个集合视图中添加一个单元格将在故事板中按以下顺序显示它: 这是它在模拟器中的外观: 我不明白如何摆脱这个观点。 所有的插图在Storyboard Size Inspector中都为零,用于收集视图。 可以肯定的是,我也有以下代码: override func viewWillLayoutSubviews() { let layout = self.collectionViewProducts.collectionViewLayout as! UICollectionViewFlowLayout let containerWidth = UIScreen.main.bounds.size.width – 40.0 let itemWidth = (containerWidth / 3.0) let itemHeight = (itemWidth / 0.75) + 30 layout.sectionInset = UIEdgeInsets(top: 0.0, left: 0.0, bottom: 0.0, right: 0.0) layout.itemSize = CGSize(width: itemWidth, height: itemHeight) } […]

alignmentUICollectionView的最后一行

据我UICollectionViewFlowLayout , UICollectionViewFlowLayoutcertificate除了最后一个部分的所有行的所有行。 因此,例如,如果没有足够的项目填充多于一行,结果是不合理的。 什么是最简单的方法来configuration或子类UICollectionViewFlowLayout以便它也certificate了一节的最后一行?