uicollectionview

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

iOS: How To make multiple column table

我们两清 提交于 2020-01-03 05:09:07
问题 I am trying to make a table using uitableview on iOS 7 and 8 . The table is like the image below I've tried doing it using uitableviewCell but the labels didn't adjusted well in iphone and iPad .. plus the auto layout was pain to handle. My question is.. Is there anyway that I can do this even with uicollectionView.. and how in details please. Any help will be appreciated 回答1: like an example. Obvisously there are many things you must configure, but I think is good start point: .h file:

UIcollectionView has slow jerky loading of images and scrolling

╄→尐↘猪︶ㄣ 提交于 2020-01-03 04:29:09
问题 I have a UICollectionView with some images in it. It is very slow and jerky to load the images on the first scroll down. After that, when the images are loaded it is fine. I guess the problem is that the images don't get loaded until the cell reaches the screen which causes a lag. I'm assuming what I need to do is load the images before they appear on the screen. I'm not sure how to do this and am obviously searching for the wrong thing as I can't find any answers. Please can someone point me

Keep UICollectionViewCell centered after Zooming with UIPinchGestureRecognizer

痞子三分冷 提交于 2020-01-03 02:51:05
问题 I'm having this issue. I change the scale and as well the transition of the view of a UICollectionViewCell , for doing zoom in the position of my fingers do the UIPinchGesture. But after that, the position of the view changes and the view go off the screen and its bounds. I want that the Gesture View get back to its correct position. This is what is happening: I have tried to assign a CGAffineTransformIdentity to the view if the center of the cell changes, but after the Scale and the

How to give width and height programatically for collection view cell in ios, swift 3

为君一笑 提交于 2020-01-03 02:01:06
问题 I tried to give the height and width for collectionViewCell , programatically. I used following method: func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { let viewWidth = self.deviceWidth/3 - 5 let viewHeight = viewWidth return CGSize(width :100,height: 100) } This didn't work. even this method didn't show as a hint. Help me with this. Is there any other delegate method to set the cell

Reuse of UICollectionViewCells during scrolling

别等时光非礼了梦想. 提交于 2020-01-02 23:15:42
问题 I'm having an issue, I have a simple UICollectionView with a static 200 cells that load images from Flickr. my CellForItemAtIndexPath looks like this: - (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath { UICollectionViewCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"FlickrCell" forIndexPath:indexPath]; cell.backgroundColor = [self generateRandomUIColor]; if(![[cell.subviews objectAtIndex:0] isKindOfClass:[PFImageView

IOS - SWIFT - CollectionView With images, loading URLs from array

蹲街弑〆低调 提交于 2020-01-02 23:15:40
问题 I have a collection view and array with URLs of different images. and when i launch the app, collection view starts to load images through the array: func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { var cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! CellView var url = arr[indexPath.row] var urls = NSURL(string: url) var data = NSData(contentsOfURL: urls!) cell

Abstract class in Swift

爷,独闯天下 提交于 2020-01-02 22:33:08
问题 I know about protocols and protocol extensions being the best way to emulate abstract classes, but what I want to do needs real abstract classes I think. I want a BaseCollectionViewCell and a BaseCollectionViewSource that work together. You'd pass an array to a subclass of the BaseCollectionViewSource and implement a method that returns a reuse identifier. The cell would be instantiated by the BaseCollectionViewSource and have a method setData that would be overridden in the concrete

How to update size of cells in UICollectionView after cell data is set?

十年热恋 提交于 2020-01-02 16:39:02
问题 So I have a UICollectionView with a different image of different size in each cell. When cellForItemAtIndexPath: is called, I update the UICollectionViewCell with a method that fetches an image asynchronously on the web and displays it full size. My problem is the size of my cell is already set prior with sizeForItemAtIndexPath. I would like it to be recalled so the cell has the downloaded image size. How can I do this? 回答1: If you have already set up your sizing, find the index of the cell