uicollectionviewcell

Different cell size in UICollectionview

一曲冷凌霜 提交于 2019-11-28 02:26:45
问题 In my iphone app,I am showing images on a collection view. I fetch the images from urls,with urls I get the image size also. eg:- let's say there are two kinds of images landscape and portrait.I get value P for portrait images and L for landscape images How to customize the collectionView cell's size ? 回答1: Use this UICollectionViewDelegateFlowLayout method - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:

Error setting text in collection view cell

巧了我就是萌 提交于 2019-11-28 01:41:25
when I nslog the value after setting it it is NULL, any word why? 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]; init your labelDisplay in custom cell. //customColectionCell.h @property(strong,nonomatic) NSString *labelText; -(void)setCellLabelText:(NSString *)labelText; //customCollectionCell.m -(id)init{ //init cellLabel and addSubView to

Enforce collectionView to have only 2 rows

偶尔善良 提交于 2019-11-28 01:31:16
I have to make one collection view so that irrespective of iphone size we have just 2 images in each row and also we need border between each row and column as shown in the image. I want like this: Joe Try this code. Just a different approach. func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize { let layout = collectionView.collectionViewLayout as! UICollectionViewFlowLayout layout.sectionInset = UIEdgeInsets(top: 6, left: 4, bottom: 6, right: 4) layout.minimumInteritemSpacing = 04

UICollectionView cellForItemAtIndexPath is nil

萝らか妹 提交于 2019-11-27 23:00:37
问题 I have a function that updates existing UICollectionView. The UICollectionView is created, I can see it, but when I want to access its cells to update it, they are nil. -(void)finishExam{ for (int i = 0; i < [self.questionsOverviewCollection numberOfItemsInSection:0]; i++) { NSLog(@"self.questionsOverviewCollection - %@",self.questionsOverviewCollection); NSLog(@"cell - %@",[self.questionsOverviewCollection cellForItemAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]]); NSLog(@

Poor UICollectionView Scrolling Performance With UIImage

感情迁移 提交于 2019-11-27 20:17:58
I have a UICollectionView in my app, and each cell is a UIImageView and some text labels. The problem is that when I have the UIImageViews displaying their images, the scrolling performance is terrible. It's nowhere near as smooth as the scrolling experience of a UITableView or even the same UICollectionView without the UIImageView. I found this question from a few months ago, and it seems like an answer was found, but it's written in RubyMotion, and I don't understand that. I tried to see how to convert it to Xcode, but since I have never used NSCache either, it's a little hard to. The poster

Creating a horizontal scrolling collectionview in Swift

元气小坏坏 提交于 2019-11-27 20:15:05
问题 How can I easily make a horizontal scrolling collectionView that fills up Cells going across the rows rather than down the columns? I want there to 5 columns and 3 rows but when there is more than 15 items I want it to scroll to the next page. I'm having alot of trouble getting this going. 回答1: Option 1 - Recommended Use custom layouts for your collection view. This is the right way to do this and it gives you a lot of control over how you want your cells to fill the collection view. Here is

Create UICollectionViewCell subclass with xib [duplicate]

拟墨画扇 提交于 2019-11-27 19:58:32
This question already has an answer here: Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error? 66 answers I'm trying to create a UICollectionViewCell subclass with linked a xib, I have do this: I have create a new xib file and I have add a UICollectionViewCell in it, then I have create this subclass file: @interface MyCell : UICollectionViewCell @property (weak, nonatomic) IBOutlet UILabel *label; @end Also I have linked in the file owner custom class the MyCell class in interface builder, and I have added a UILabel , then in

Reloading a UICollectionView using reloadData method returns immediately before reloading data

爱⌒轻易说出口 提交于 2019-11-27 19:15:48
问题 I need to know when reloading a UICollectionView has completed in order to configure cells afterwards (because I am not the data source for the cells - other wise would have done it already...) I've tried code such as [self.collectionView reloadData]; [self configure cells]; // BOOM! cells are nil I've also tried using [self.collectionView performBatchUpdates:^{ [self.collectionView reloadData]; } completion:^(BOOL finished) { // notify that completed and do the configuration now }]; but when

the behavior of the UICollectionViewFlowLayout is not defined, because the cell width is greater than collectionView width

◇◆丶佛笑我妖孽 提交于 2019-11-27 19:08:28
问题 2015-08-18 16:07:51.523 Example[16070:269647] the behavior of the UICollectionViewFlowLayout is not defined because: 2015-08-18 16:07:51.523 Example[16070:269647] the item width must be less than the width of the UICollectionView minus the section insets left and right values, minus the content insets left and right values. 2015-08-18 16:07:51.524 Example[16070:269647] The relevant UICollectionViewFlowLayout instance is , and it is attached to ; animations = { position=; bounds.origin=;

UICollectionView do not reuse cells

半世苍凉 提交于 2019-11-27 19:07:25
I am having trouble with reuse cells and UICollectionView on iOS 7. My code works fine on iOS 6 but in iOS 7 it does not reuse the cell after calling dequeueReusableCellWithReuseIdentifier (do not call prepareForReuse ). Even this code https://developer.apple.com/library/ios/samplecode/CollectionView-Simple/Introduction/Intro.html#//apple_ref/doc/uid/DTS40012860 does not reuse cell on iOS7 (but works well on iOS6), on every dequeueReusableCellWithReuseIdentifier it creates a new cell and deallocates the old one. Is there some new stuff that prevents cells to be reused? My cells are big enough