uicollectionviewcell

UICollectionViewCell Only Updates After Scrolling

你说的曾经没有我的故事 提交于 2019-12-08 03:33:25
问题 I've got an issue with my UICollectionView where my cells are always initiated blank/in a default state with no data. The data only appears in the cells after scrolling them in and out of view. Thoughts? Thanks. CODE: -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifier = @"EquipmentCell"; APInventoryCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier

Issue with nested UICollectionViews

拟墨画扇 提交于 2019-12-08 02:34:09
问题 I have 2 nested UICollectionViews. The delegate for the outer collection view is the main view controller, and the inner collection views delegate is the UICollectionCell of the outer collection view. The outer collection view has only a label and the inner collection view in it - normally there would be seven of these, the inner collection view should contain 3 or 4 cells (containing 3 labels). The problem is that the inner collection view only seems to get updated twice (for the first 2

Adding multiple buttons + receiving touchUpInside event inside UICollectionViewCell SWIFT programmatically

夙愿已清 提交于 2019-12-07 19:14:13
问题 I am trying to build a CollectionView for a list all programmatically in Swift without using Storyboard. I was able to add a tap gesture event to the cell. However, When I added a set of buttons to the UICollectionViewCell's contentView, the buttons do not receive any touch events. Inside Controller let sampleCollectionView = UICollectionView(frame: (..), collectionViewLayout: layout) //Register the UICollectionViewCell inside UICollectionView sampleCollectionView.registerClass

Remove UICollectionView cells on edit button

柔情痞子 提交于 2019-12-07 13:37:05
问题 I am using a UICollectionView to retrieve images and labels stored in the Cloud database Parse. I now need an option that will let me delete a certain image and its corresponding label. I am looking for something such as the typical iPhone "Edit" button on the top right hand corner which displays a swipe animation with a delete button next to the cell. I'm aware that such a thing can be done on a UITableView through [[self tableView] setEditing:YES animated:YES]; but I can't seem to find the

how to use center vertically cells in collection view in paging mode in swift 4?

淺唱寂寞╮ 提交于 2019-12-07 09:09:07
问题 I read How to vertically center UICollectionView content But when I used the codes here func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { let navBarHeight = self.navigationController?.navigationBar.frame.height let collectionViewHeight = (self.collectionView?.frame.height)! - navBarHeight! let itemsHeight = self.collectionView?.contentSize.height let topInset = ( collectionViewHeight -

Cell disappearing after scrolling 2 - 3 times in UICollectionView

浪子不回头ぞ 提交于 2019-12-07 08:23:30
I'm facing a strange issue while scrolling my UICollectionView . It's showing a blank view without any cells in it. It strangely hides my cell or removes my cell, I don't know, but I'm unable to find any solution. I have tried these solutions from SO: 1st : Tried to create custom class of UICollectionViewFlowLayout and do as directed with all different methods but unable to solve my issue. 2nd : Tried below method to reattribute and recalculate my cell size : -(BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds { return YES; } Links I followed : Que1: UICollectionView's cell

could not dequeue a view of kind: UICollectionElementKindCell with identifier

不问归期 提交于 2019-12-07 08:12:37
问题 I have UICollectionView, but it seems that I set up everything right. But I get the error: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier PeopleCellForList - must register a nib or a class for the identifier or connect a prototype cell in a storyboard' My storybord: My code is: @interface PeopleCellForList : UICollectionViewCell @end @implementation PeopleCellForList @end #pragma mark - UICollectionView Datasource - (NSInteger)collectionView:(UICollectionView *

iOS: UICollectionViewCell auto adjust size according to screen size

自作多情 提交于 2019-12-07 06:16:59
问题 I am trying to create 10 cells in the collection view(same size as the screen). When I run my app in iphone5s simulator, the view contains exactly 5 cells. But when I switch to iphone6p simulator, the view contains more than 5 cells. How should I adjust the cell size so that the number of cells in screen are consistent across different screen sizes? 回答1: -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:

Fast Enumeration through UICollectionView Cells - Swift

我的未来我决定 提交于 2019-12-07 02:10:26
问题 I am trying to fast enumerate through all of my collection view cells, however this implementation below is giving me a warning. for cell in self.collectionView?.visibleCells() as [UICollectionViewCell] { // Do Stuff } Error below appears on first line: Operand of postfix '?' should have optional type; type is '(UICollectionView, cellForItemAtIndexPath: NSIndexPath) -> UICollectionViewCell' I've tried messing around with optionals and had this working in Xcode 6 Beta 6, but to no avail in

The best way of adding countdown label with timer in UICollectionViewCell which works fine even after cell is being reused

心已入冬 提交于 2019-12-06 14:56:19
问题 I have a list of items which are presenting to the user in UICollectionView . These items have a countdown label to show the remaining time that the item is available. I used a Timer in UICollectionViewCell to show the remaining time like: OperationQueue.main.addOperation { var remaingTimeInterval = self.calculateRemainigTime(remainingTime: remainingTime) if remaingTimeInterval > 0 { self.timerLabel.isHidden = false self.timer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true, block: