uicollectionviewcell

UICollectionView Layout like SnapChat?

流过昼夜 提交于 2019-11-26 23:13:15
how do we create a UICollectionViewLayout like the SnapChat's stories? Any ideas please? I'd like to have a solution without external library. Larme Based on a precedent answer adapted to your issue: -(id)initWithSize:(CGSize)size { self = [super init]; if (self) { _unitSize = CGSizeMake(size.width/2,80); _cellLayouts = [[NSMutableDictionary alloc] init]; } return self; } -(void)prepareLayout { for (NSInteger aSection = 0; aSection < [[self collectionView] numberOfSections]; aSection++) { //Create Cells Frames for (NSInteger aRow = 0; aRow < [[self collectionView] numberOfItemsInSection

How do I set collection view's cell size via the auto layout

折月煮酒 提交于 2019-11-26 22:50:54
问题 Hi I'm trying to resize the cell via the auto layout . I want display the cell by the 3 by 3. First Cell's margin left=0 Last Cell's margin right=0 And all of the cell's space has 1pt. Like an instagram . Should I set to Cell's Size? I want set constraint via the Autolayout. I also trying to set cell's size using the code. Here is my code: func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -

UICollectionview Scrolling choppy when loading cells

亡梦爱人 提交于 2019-11-26 22:35:49
问题 I have a gallery in my app utilizing a UICollectionView . The cells are approximately 70,70 size. I am using ALAssets from the ALAssetLibrary in the gallery which I have stored in a list. I am using the usual pattern for populating the cells: -(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { mycell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath]; mycell.imageView.image = [

UICollectionView adding image to a cell

家住魔仙堡 提交于 2019-11-26 22:35:44
I'm working on a project which uses UICollectionView to display data which may or may not have an image. The way I'm using is to check if the image url is not null, then add an ImageView onto the cell. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { if (question.picture != (id)[NSNull null]) { //add AsyncImageView to cell imageView.contentMode = UIViewContentModeScaleAspectFill; imageView.clipsToBounds = YES; imageView.tag = IMAGE_VIEW_TAG; [cell addSubview:imageView]; [[AsyncImageLoader sharedLoader]

Error setting text in collection view cell

只愿长相守 提交于 2019-11-26 21:58:09
问题 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]; 回答1: init your labelDisplay in custom cell. //customColectionCell.h @property(strong,nonomatic) NSString *labelText; -(void

Enforce collectionView to have only 2 rows

浪尽此生 提交于 2019-11-26 21:55:51
问题 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: 回答1: 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

Poor UICollectionView Scrolling Performance With UIImage

て烟熏妆下的殇ゞ 提交于 2019-11-26 20:16:20
问题 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

UICollectionView do not reuse cells

萝らか妹 提交于 2019-11-26 19:45:29
问题 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

UICollectionView registerClass: forCellWithReuseIdentifier method breaks UICollectionView

偶尔善良 提交于 2019-11-26 19:24:26
问题 What's the role of registerClass:forCellWithReuseIdentifier: method? According to Apple's developer documentation it's supposed to "Register a class for use in creating new collection view cells." When I try to use it my project I get a black collection view. When I delete it everything works fine. #define cellId @"cellId" #import "ViewController.h" #import "Cell.h" @interface ViewController () @property (weak, nonatomic) IBOutlet UICollectionView *collectionView; @property(strong, nonatomic

How do I display the standard checkmark on a UICollectionViewCell?

橙三吉。 提交于 2019-11-26 17:58:52
问题 I'm designing an iOS app with a UICollectionView, and I'd like users to be able to select multiple items within this view. It seems there's a standard style of checkmark Apple uses in this kind of situation. For example, in the image below you can see it when selecting multiple photos in a share sheet. According to the documentation, you are responsible for updating the UI of your cells to reflect their selection state. I know on a UITableViewCell you can set the accessoryType property to add