uicollectionviewlayout

Using Custom Layout Causes collectionViewFlowLayout delegate function not being called

こ雲淡風輕ζ 提交于 2019-12-25 09:47:49
问题 I am using TRMosaicLayout to achieve a SnapChat like layout. However, after using it, I noticed that viewForSupplementaryElementOfKind is no longer called. Any thoughts? func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { print("THIS FUNCTION IS NO LONGER CALLED"); var view: UICollectionReusableView! = UICollectionReusableView(); switch kind { case UICollectionElementKindSectionFooter:

Dynamic UICollectionViewCell width with respect to frame width and aspect ratio

独自空忆成欢 提交于 2019-12-25 09:08:15
问题 This is a follow up question from UICollectionViewCell dynamic sizing for 4.4 and 5.5 inch While that solution is great, I'd like to generate a dynamic amount of item cells (kCellsPerRow) within the UIVIewController based on the device's width, aspect ratio, and amount of total items I have to display. I just can't figure out how to calculate the right amount of kCellsPerRow so that they are not too resized once they hit an aspect ratio limit. Here's what I have so far: var kCellsPerRow =

Aligning right to left on UICollectionView with contents

空扰寡人 提交于 2019-12-25 01:39:16
问题 I tried with the following question: Aligning right to left on UICollectionView but it's not achieved my goal. What I was tried: In viewDidLoad() : collectionView.transform = CGAffineTransform(scaleX: -1.0, y: 1.0) In cellForItemAtIndexPath() : cell.transform = CGAffineTransform(scaleX: -1.0, y: 1.0) My current CollectionView is on the left, but I want it to look like the CollecitonView on the right. dataSource = ["item1","item2","item3","item4","item5","item6"] Update: Change

How to expand collectionview cell on didselect to show more info?

前提是你 提交于 2019-12-24 14:43:23
问题 I want to animate my collectionview cell so that when I touch it, a mapview slides out from underneath it and basically expands into the space, by pushing the cell underneath it down a little bit. I tried using this: UICollectionView: Animate cell size change on selection, but was unable to get it to work properly. Here what I tried. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { [((FeedCell *)[collectionView

Issue with placing cells in custom flow layout of UICollectionViews

拟墨画扇 提交于 2019-12-24 07:40:06
问题 I am trying to create a tag flow layout. To do this I followed a very nice tutorial https://codentrick.com/create-a-tag-flow-layout-with-uicollectionview/ I managed to create and customize the flow layout, but the cells are not aligned properly some times. Here is the screenshot from iphone 4S. I have two header sections also As you can see in section 1, the tags are not placed correctly. I am not understanding what is causing this issue. Here is my custom flow layout class import UIKit class

“targetContentOffset” UICollectionViewFlowLayout not working properly

会有一股神秘感。 提交于 2019-12-24 01:33:26
问题 I have a requirement to keep UICollectionViewCell center aligned in portrait mode. Final result should be like : animation I'm using this code to do this: override public func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint, withScrollingVelocity velocity: CGPoint) -> CGPoint { var layoutAttributes: Array = layoutAttributesForElements(in: collectionView!.bounds)! if layoutAttributes.count == 0 { return proposedContentOffset } var firstAttribute:

scrollToItem at indexPath at .top hides cell under header when sectionHeadersPinToVisibleBounds

天大地大妈咪最大 提交于 2019-12-23 13:11:45
问题 Using the following configuration: let layout = UICollectionViewFlowLayout() layout.sectionHeadersPinToVisibleBounds = true let collectionViewController = UICollectionViewController(view.bounds, collectionViewLayout: layout) The following code will scroll to the given index path but the item will be under and covered by its header: let indexPath = IndexPath(section: 0, row: 2) collecitonView.scrollToItem(at: indexPath, at: .top, animated: true) How do I get the collection view to scroll to

UICollection View causes “UICollectionViewFlowLayoutBreakForInvalidSizes” on smaller devices

蓝咒 提交于 2019-12-23 13:03:58
问题 On an iPhone 6 Plus, the collection view cells are fine, but when testing on another device size like the iPhone 5, i'm bombarded with " 017-06-15 01:59:25.744 HyperTest[3865:8825385] The behavior of the UICollectionViewFlowLayout is not defined because: 2017-06-15 01:59:25.744 HyperTest[3865:8825385] 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. 2017-06-15 01:59:25.745

How to get the index path of a UICollectionView header?

♀尐吖头ヾ 提交于 2019-12-23 12:28:25
问题 Using the view's indexPathForItemAtPoint, I will get an index path for a cell, but never a UICollectionReusableView (header/footer) -- as it always returns nil. 回答1: You should make your own dictionary mapping index paths to header views. In your collectionView:viewForSupplementaryElementOfKind:atIndexPath: method, put the view into the dictionary before returning it. In your collectionView:didEndDisplayingSupplementaryView:forElementOfKind:atIndexPath: , remove the view from the dictionary.

How to stack UICollectionView sections

泄露秘密 提交于 2019-12-23 08:29:28
问题 I originally tried doing this with two UICollectionViews stacked on top of each other. However getting it to scale right was nightmare with Auto-layout (I'm a novice iOS developer so that is more a critique of my skill than Auto-layou t). I'd like to stack two sections of UICollectionView cells on top of each other like this: +----------------------+ |+-Section 0---------->| | +-------+ +-------+ | | | | | | | | | | | | | | |Cell 0 | |Cell 1 |+-> | | | | | | | | | | | | | +-------+ +-------+