uicollectionviewcell

Swift: How to continuously adapt a UICollectionViewCell height to a UITextView while writing in it?

微笑、不失礼 提交于 2020-01-04 09:06:16
问题 Good afternoon. I've struggled with this "feature" for my iOS app for some hours now and I'm in need of some help. Question: How should I implement so that when a user types in the UITextView increases in size (only the bottom margin) and the cell increases its height to fit the UITextView dynamically meanwhile? I can't figure out how to tackle it. Research: After some searching I came upon Dynamically change cell's height while typing text, and reload the containing tableview for resize as

UICollectionView - Image is getting set randomly

白昼怎懂夜的黑 提交于 2020-01-04 06:36:07
问题 I am using collectionView in my App. I am setting image for the cell backgroundView in didSelect delegate. But When i select one cell indexPath the image is getting set for 3 cell indexPath. When i scroll the collectionView the images are getting changed randomly? Please Help me. thanks in advance. - (void)viewDidLoad { [super viewDidLoad]; [collection registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:uio]; } - (NSInteger)collectionView:(UICollectionView *)collectionView

CollectionView with background Image

和自甴很熟 提交于 2020-01-04 00:31:48
问题 I use collectionView with a transparent background and imageView under the CollectionView. I change the ImageView depending on the cell that is in the middle, but the image are not displayed correctly, how you can solve it, an example of how it should look and looks below Gif: how it should work: how it works: func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionViewRecomend.dequeueReusableCell

CollectionView with background Image

安稳与你 提交于 2020-01-04 00:31:33
问题 I use collectionView with a transparent background and imageView under the CollectionView. I change the ImageView depending on the cell that is in the middle, but the image are not displayed correctly, how you can solve it, an example of how it should look and looks below Gif: how it should work: how it works: func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionViewRecomend.dequeueReusableCell

How to make UICollectionview cell height dynamic?

江枫思渺然 提交于 2020-01-03 18:14:30
问题 I have a UIcollectionview . There are some cells of the Collectionview. Inside that CollectionviewCell there is a textview. The textview's content is dynamic. So the cell height should be dynamic. How to do that? 回答1: 1-Add UICollectionViewDelegateFlowLayout protocol. 2-Conform to protocol by implement the sizeForItemAtIndexPath method in your ViewController . 3-Use the index of the cell to get the text you have and calculate the height and width of it. class ViewController: UIViewController

how to redraw non-visible UICollectionViewCell's after rotation ready for when reuse occurs?

北城余情 提交于 2020-01-03 13:45:07
问题 How to redraw non-visible UICollectionViewCell's ready for when reuse occurs??? One approach I thought of was per the code in the Layout Cell prepareForReuse function, however whilst it works it non-optimal as it causes more re-drawing then required. Background: Need to trigger drawRect for cells after an orientation change that are not current visible, but pop up to be used and haven't been redraw, so so far I can only see that prepareForReuse would be appropriate. Issue is I'm re-drawing

Can't select item in UICollectionView programmatically

最后都变了- 提交于 2020-01-03 10:17:09
问题 I'm trying to set a default item when the view is loaded this way: override func viewDidLoad() { super.viewDidLoad() self.collectionView.delegate = self self.collectionView.dataSource = self self.collectionView.allowsSelection = true self.collectionView.allowsMultipleSelection = true } I'm trying to select an item in the viewDidAppear method: override func viewDidAppear(_ animated: Bool) { DispatchQueue.main.async(execute: { self.collectionView.selectItem(at: IndexPath(item: 0, section: 0),

UICollectionviewCell Animations

人走茶凉 提交于 2020-01-03 06:21:06
问题 I want to animate the collectionview cells,the animations should be like this: First Cell Appear and then after some delay second cell will appear with some animations ,this will go on like this for all the cells. How to achieve this? 回答1: A solution would be to create the datasource incrementally so you add a cell after a set timed delay. Once added, insert Make a call to set up a timer to add to your dataSource with whatever delay you like [NSTimer scheduledTimerWithTimeInterval:0.05 target

Change UICollectionViewCell content and nib layout based on data

孤街醉人 提交于 2020-01-03 05:54:34
问题 I have a UICollectionView that is displaying many UICollectionViewCells that I have subclassed as CardCell. I pass the variable "type" to the CardCell in - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath I want the CardCell class to be able to load a different Nib file depending on what type is passed in. The different types need to have different layouts. The problem is I cannot figure out where to change this in my

Change UICollectionViewCell content and nib layout based on data

混江龙づ霸主 提交于 2020-01-03 05:54:06
问题 I have a UICollectionView that is displaying many UICollectionViewCells that I have subclassed as CardCell. I pass the variable "type" to the CardCell in - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath I want the CardCell class to be able to load a different Nib file depending on what type is passed in. The different types need to have different layouts. The problem is I cannot figure out where to change this in my