uicollectionviewlayout

Customising position of header in UICollectionView layout causes NSInternalInconsistencyException error

空扰寡人 提交于 2019-12-21 08:46:07
问题 I am trying to customise the positions of the headers in a UICollectionView using a subclassed UICollectionViewFlowLayout class (based loosely on the code for stacked headers which is shown enter link description here). As a minimal test, let's say I just want to add a fixed offset to the position of all headers: I add all headers to the array returned by layoutAttributesForElementsInRect so that all are always processed (this may be the cause of the problem, I'm not sure) I then update each

Autolayout is not resizing Uicollectionviewcell items when animating between layouts

旧巷老猫 提交于 2019-12-21 06:36:31
问题 I have a uicollectionview cell with an image view inside that I want to resize when I switch to a larger 'zoomed in' layout. I have placed constraints inside the cell that does resize the image view when the zoomed in layout is displayed. I am using uicollectionview setLayout animated method. The problem is the image does not scale with animation only the collection view cell does. The image seems to just jump into its end size with no interpolation. So the animation looks extremely choppy.

Expanding UICollectionView and its cell when tapped

拜拜、爱过 提交于 2019-12-21 06:28:26
问题 I am trying to make a transition animation like the demonstration in the link here. So when I clicked the cell, it expands and covers the whole screen. Here are my codes(I have to admit that I am not familiar with CollectionView)` import UIKit class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate { @IBOutlet weak var mainDesLabel: UILabel! @IBOutlet weak var collectionView: UICollectionView! @IBOutlet weak var secDesLabel: UILabel! let searchBar =

Keep size of a custom cell in a UICollectionView when moving

邮差的信 提交于 2019-12-21 05:13:37
问题 I have a horizontal collection view and every cell has it's own width. I use the default UICollectionViewFlowLayout. When rearranging, cell inherits the width of the cell which it overlays during this movement, what I don't want. Any idea, how to avoid this behavior? 回答1: So, If you have the UICollectionView with cells of different sizes and you'd like to keep their sizes when moving using the standard UICollectionViewFlowLayout use this: extension UICollectionViewFlowLayout { @available(iOS

Preventing “wrapping” of items in UICollectionView

拟墨画扇 提交于 2019-12-21 04:34:04
问题 I need a UICollectionView to display a grid that is potentially larger than the visible frame in both width and height, while maintaining row and column integrity. The default UICollectionViewFlowLayout allows sections to scroll off-screen, but it wraps items within a section to keep them all on-screen, which screws up my grid. Recognizing that UICollectionView is a subclass of UIScrollView , I tried just manually setting the collection view's content size property in viewDidLoad: self

Swift, Change width of UICollectionViewCell and UILabel(inside the cell) programmatically

那年仲夏 提交于 2019-12-21 04:13:28
问题 I've set the width of a cell(UICollectionViewCell) to be equal to the width of the UICollectionView and I'm trying to do exactly the same thing with the UILabel that is included inside that cell. I think the code below explains exactly what I'm trying to achieve. So i've read some question here in SO and also a couple of tutorials but I'm still not sure how I can achieve this. In a couple of questions it was saying about using collectionViewLayout but I'm really struggling on how to use it

Assertion Failure in UICollectionViewData validateLayoutInRect on ios7

随声附和 提交于 2019-12-21 03:18:25
问题 Assertion Failure in UICollectionViewData validateLayoutInRect on iOS7. I am trying to delete all UICollectionView items, one by one, using a for loop; I posted my code below. I delete the UICollectionView items using deleteItemsAtIndexPaths . It's working perfectly on iOS6 , but crashes in iOS7 with this exception: Assertion Failure in UICollectionViewData validateLayoutInRect I delete the object from collectionArray then self.collectionView , one by one, using indexPath . When I delete the

UICollectionView doesn't bounce when datasource has only 1 item

半城伤御伤魂 提交于 2019-12-20 17:32:56
问题 I have a UICollectionView with a custom UICollectionViewFlowLayout. It scrolls horizontally and only shows one item at a time (full height). I have pagingEnabled = YES so that it sticks to pages. The UICollectionView shows photos within a particular day. I initially had buttons to change the day +/- 1 day, but I thought it would be neat if the user could pull on the collection view past the first or last image (past a predetermined threshold) to change the day. I implemented this using the

Drag and reorder - UICollectionview with sections

梦想的初衷 提交于 2019-12-19 03:57:33
问题 Is that possible to do drag and reorder from one section to another section from collectionview - iOS 9. Every time am dragging from 1st section to drop at 4th section am getting below crash, Assertion failure in -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering: func collectionView(collectionView: UICollectionView, moveItemAtIndexPath sourceIndexPath: NSIndexPath,toIndexPath destinationIndexPath: NSIndexPath) { let sequence = ArrayrelatedSequence

How do I alternate a UICollectiveViewCell's background color based on row?

穿精又带淫゛_ 提交于 2019-12-18 12:44:18
问题 I know this is fairly easy for UITableViewCells but I'm not sure how to approach this using a UICollectionView. EDIT. Pictures for clarification. Text content of the cells are not the same here but they should be. In landscape: In portrait: I tried to naively switch the color of my cell's text label with the cell's background color based on the index path's row property in the cellForItemAtIndexPath: method. However Index Path's row property isn't really a row in UICollectionViewFlowLayout.