uicollectionviewcell

UIButton image for normal state in collectionview cell repeats itself every four cells

試著忘記壹切 提交于 2019-12-17 21:38:51
问题 I'm trying to set an image for a button's normal state which is located in a collectionView cell. When the button is pressed the image changes. The problem is every four cells it repeats the same image as the original cell when the button is pressed. Is there a way to not have it repeat itself and when the button is pressed its only for that individual cell? Here is the code: class FavoritesCell: UICollectionViewCell { var isFavorite: Bool = false @IBOutlet weak var favoritesButton: UIButton!

Create UICollectionViewCell subclass with xib [duplicate]

三世轮回 提交于 2019-12-17 15:47:24
问题 This question already has answers here : Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error? (68 answers) Closed 4 years ago . 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

Getting button action : UICollectionView Cell

放肆的年华 提交于 2019-12-17 15:36:35
问题 I have created a UICollectionViewCell by nib and added a button inside it and created a .h and .m files added the class to the nibs file's owner .then wrote a button action in the .m connected it via outlet. The collection view is populating fine ,but cannot get the buton action triggered. I think the delegate for collection cell is called. How can i get the button action? 回答1: I had this problem as well. No subviews would receive touch events. While Scott K's workaround does work, I still

Dynamic cell width of UICollectionView depending on label width

廉价感情. 提交于 2019-12-17 10:13:12
问题 I have a UICollectionView, that loads cells from reusable cell, which contains label. An array provides content for that label. I can resize label width depending on content width easily with sizeToFit. But I cannot make cell to fit label. Here's the code - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. arrayOfStats = @[@"time:",@"2",@"items:",@"10",@"difficulty:",@"hard",@"category:",@"main"]; } - (NSInteger)collectionView:

UICollectionView update a single cell

泄露秘密 提交于 2019-12-17 09:16:10
问题 I am attempting to update a single cell inside a UICollectionView , specifically I am just trying to update an image in that specific cell detonated by cell.imageView . [self.collectionView reloadData] is not really an option because it makes the whole collection view flash. [self.collectionView beginUpdates] is not a thing in a UICollectionView it seems. I understand I may be able to use: [self.collectionView performBatchUpdates:^{ //do something } completion:nil]; I am not exactly sure what

UICollectionView's cell disappearing

六眼飞鱼酱① 提交于 2019-12-17 06:27:36
问题 What's happening Currently I have an application that uses two UICollectionViews inside a UITableView . This way I create a Pulse News look like application. My problem with this is that sometimes the 6th and 11th row disappears completely, leaving a blank space where it should be the cell. I wouldn't actually mind, if all the cells were like this (and this way I could assume that I wasn't doing things correctly), but the thing is, is just happening with those specific ones. My theory The 6th

UICollectionView adding image to a cell

喜欢而已 提交于 2019-12-17 06:13:29
问题 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;

UICollectionView Layout like SnapChat?

只愿长相守 提交于 2019-12-17 04:38:13
问题 how do we create a UICollectionViewLayout like the SnapChat's stories? Any ideas please? I'd like to have a solution without external library. 回答1: 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++) { /

UICollectionView Layout like SnapChat?

心已入冬 提交于 2019-12-17 04:38:00
问题 how do we create a UICollectionViewLayout like the SnapChat's stories? Any ideas please? I'd like to have a solution without external library. 回答1: 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++) { /

Why two collection views in two table view cells won't work in Swift 4?

不想你离开。 提交于 2019-12-14 03:53:31
问题 I read similar questions such as how to have multiple collection view in multiple table view cells and I connected my collection views cells and use identifier names for them but I don't know why I receive this Error: * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier extera_infoCollectionViewCell - must register a nib or a class for the identifier or connect a prototype cell in