uicollectionview

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

UICollectionView is very slow when inserting or deleting many items

丶灬走出姿态 提交于 2020-01-03 19:42:45
问题 I'm trying to insert and delete a large amount of items (say, 20,000) from a collection view, and the operation takes a very long time. The test fixture I created is composed of the following: UICollectionView with no configuration besides a data source. Default UICollectionViewFlowLayout . Data source that returns either 10K or 30K items depending on a BOOL variable. Button to toggle that variable. When set to YES , 20K items are being added to the data source (just by changing

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

Animate UICollectionView header height change

谁说胖子不能爱 提交于 2020-01-03 17:25:26
问题 I am currently using a UICollectionView with a header, and am wondering how to animate and expand the header height when required. I'm trying to emulate the functionality found in the Expedia app for iPhone, where tapping the image expands the header cell to reveal the image in the centre: I've been trying this for a while so any suggestions would be great. 来源: https://stackoverflow.com/questions/32933476/animate-uicollectionview-header-height-change

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

In Swift, how would you write the scrollViewWillEndDragging withVelocity targetContentOffset method?

▼魔方 西西 提交于 2020-01-03 12:59:07
问题 How would one write this in Swift ? Update : posted the method I'm trying to convert, originally posted a different method that was not what I was trying to covert This works in Objective C, but not Swift. I get conversion errors when I try to use ceilf and floorf with CGFloat . - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset { float pageWidth = 200 + 30; // width + space float currentOffset =

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),

UICollectionView didSelectRowAtIndexPath doesn't work

柔情痞子 提交于 2020-01-03 09:57:21
问题 The didSelectRowAtIndexPath method doesn't work in my app. I don't get printed any output with NSLog : - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { PhotoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath]; PFObject *imageObject = [self.imageFilesArray objectAtIndex:indexPath.row]; PFFile *imageFile = [imageObject objectForKey:@"file"]; [imageFile

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