uicollectionviewcell

Swift How to get the centre cell in a collectionView and resize it when scrolling?

只谈情不闲聊 提交于 2019-12-19 09:58:50
问题 I have a horizontal collectionView and i would like to manage that when scrolling it, the centre cell becomes larger. So, each time a cell is the center cell it will be larger than the others. Check the image beneath. Can anyone help me with the best way to do this? Thanks in advance! My code so far: import UIKit class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate { @IBOutlet var horizontalCollectionView: UICollectionView! @IBOutlet var

How to set a UILabel in UICollectionViewCell

末鹿安然 提交于 2019-12-19 09:42:30
问题 I have an app with a UIViewController with a UICollectionView IBOutlet in it. The cell in the UICollectionView is MyCustomCell and has this method setting its UILabel: -(void)setCellLabel:(NSString *)value{ NSLog(@"settinglabel"); cellLabel.text = @"hardcode"; //added for testing purposes } The cell has the property Class type identifying it as MyCustomCell in storyboard and its dequeue identifier as well. The UIViewController adopts the datasource and delegate protocols. The IBOutlet UILabel

Swift 3: How to center horizontally the last row of cells in a UICollectionView with only one section?

和自甴很熟 提交于 2019-12-19 09:14:24
问题 I'm using a UICollectionView with only one section. Here's some visualization: [ x x x ] [ x x x ] [ x x ] If the last row in the UICollectionView does not have all 3 cells filled, I'd like to center those cells like so: [ x x x ] [ x x x ] [ x x ] I've tried to implement solutions from the following places: How to center horizontally UICollectionView Cells? How to center align the cells of a UICollectionView? However, the solutions shifts all the cells, and I'd like to only shift the LAST

Swift - could not dequeue a view of kind: UICollectionElementKindCell with identifier

孤街浪徒 提交于 2019-12-19 05:31:16
问题 I got this error message when trying to load UICollectionView. 2015-07-23 16:16:09.754 XXXXX[24780:465607] Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier CollectionViewCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard' First throw call stack: My code @IBOutlet var collectionView: UICollectionView! func collectionView

How to set UILabel on UICollectionViewCell?

♀尐吖头ヾ 提交于 2019-12-19 04:53:58
问题 I've done this several dozen times with custom and standard UITableView cells. All my outlets are connected. The UILabel is a subview of my UICollectionViewCell in IB. My UICollectionViewCell object inherits the proper class in identity inspector. How do I set UILabel on UICollectionViewCell ? MyCell.m -(void)setCellName:(NSString *)cellName { self.cellLabel.text = cellName; } ViewController.m - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:

UICollectionViewCell gets hidden randomly

喜你入骨 提交于 2019-12-18 17:48:09
问题 I have a UIView in which I am adding a UICollectionView to act as a banner view to look like a carousel. The Viewcontroller in which UIView is present, is part of pageviewcontroller . PageVC --> UIViewController --> UIView --> UICollectionView . Each VC has its own banner, so when the page is swiped, I reload the collectionView with the respective data and I am able to see it. Now if visit a page which I already visited, the collectionview cell disappears. The collectionview is visible but

UICollectionViewCell using prototype sizes

我只是一个虾纸丫 提交于 2019-12-18 16:56:56
问题 I have an UICollectionView with three different prototype cells, each of which with different heights set via Storyboard. During runtime, the Collection View uses its own cell size, ignoring my Storyboard ones. I am currently using collectionView:layout:sizeForItemAtIndexPath: with a couple conditionals to set each CGSize straight. Is there a better way to set the cell sizes? I don't seem to be able to retrieve the Storyboard size each cell has, and CGSizeMake seems too hardcoded and not

Access a UICollectionView's parent UIViewController

点点圈 提交于 2019-12-18 15:52:55
问题 My question is fairly straightforward. I have a UIViewController containing a UICollectionView. In initialising my cells, I add a gesture recogniser to each of them so that when you tap and hold it calls a function with a selector. This function then creates a UIAlertController which I want to present. (Basically, you hold a cell, it asks you if you want to delete it and if you say yes it eliminates it from the CollectionView) The problem is that I can't present a UIAlertController from my

Trying to override “selected” in UICollectionViewCell Swift for custom selection state

China☆狼群 提交于 2019-12-18 12:47:47
问题 I am trying to implement a custom selection style for my cells in a UICollectionView. Even though it is easily possible to do this manually in the didSelect and didDeSelect methods I would like to achieve this by manipulating the "selected" variable in UICollectionViewCell. I have this code for it: override var selected: Bool { get { return super.selected } set { if newValue { self.imageView.alpha = 0.5 println("selected") } else if newValue == false { self.imageView.alpha = 1.0 println(

UICollectionView Cell + UiLabel with AutoLayout

与世无争的帅哥 提交于 2019-12-18 11:48:48
问题 I'm trying to pin an UILabel to it's parent cell. I added four constraints (top, leading, trailing, bottom) which works fine on iOS 8.0 but not on iOS 7.X . Please see image below: [Click here for full size] What am I doing wrong? Please advise! EDIT #1 It seems it's only broken since Xcode 6 GM. My approach was working fine in Xcode 6 beta 7. Moreover, if I decrease the inner view's width, it throws the following warning: 2014-09-10 19:58:28.109 Test[57827:60b] Unable to simultaneously