uicollectionview

Self-sizing cells with UICollectionViewCompositionalLayout

大兔子大兔子 提交于 2021-01-29 05:08:34
问题 I have a view controller that displays a collection view with self-sizing cells. The collection view has one section that scrolls horizontally. It looks like this: Problem The collection view behaves unexpectedly when the view controller is presented using the default pageSheet style on iOS 13+. When pulling upward on the sheet, cells may appear to resize like the cell labeled "Rectify" below: When pulling upward on the sheet, the content may shift horizontally. Sometimes, cells may disappear

iOS: Custom top segmented control works as expected only when using debugger

懵懂的女人 提交于 2021-01-28 19:02:15
问题 I'm trying to create a custom top swipe menu that has a moving resizing orange bar that denotes which tab is selected. This is an extremely common design and I'm just doing this for practice as I am new to swift. You navigate by either swiping through the bottom collectionView or you can select a tab on the top menu. The top menu is also just a collectionView and is scrollable as well. As you can see below (first gif), my problem is that when I try to go back to the first tab, whether by

ios UICollectionView cell selecting and deselecting issue

人盡茶涼 提交于 2021-01-28 08:23:04
问题 Im using UIcollection view as my tabbar when I scroll collection view horizontally previous selected cell will not deselect when i select new one this is my code to change colour when i select a cell and deselect a cell var selectedIndexPath : IndexPath = [] func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { if let cell = collectionView.cellForItem(at: indexPath) as? BottomCollectionViewCell { cell.contentView.backgroundColor = UIColor.orange cell

Display UICollectionView with 2 columns of equal size square cells

耗尽温柔 提交于 2021-01-28 06:48:08
问题 I'm trying to accomplish the following: I've followed the answer in this question, but I get the image below: This is the code for the collection view controller: class MainMenuViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout { @IBOutlet var collectionView: UICollectionView! @IBOutlet weak var dateTimeLabel: MarqueeLabel! @IBOutlet weak var iconButton: UIButton! @IBOutlet var imageView: UIImageView! var iconButtonTimer:

Select the UITableView on UICollectionView selection

旧时模样 提交于 2021-01-28 01:47:52
问题 I have a UICollectionView inside UITableViewCell . When I select the a tableView row, I do not want the didSelectItemAtIndexPath: method of UICollectionView to get called. Instead I want didSelectRowAtIndexPath: method of UITableView to get called. How would I call didSelectRowAtIndexPath: in didSelectItemAtIndexPath: ? 回答1: Set collectionView.allowsSelection = NO to disable selection. OR in the didSelectItemAtIndexPath method, grab the UITableViewCell and call the delegate which is the table

UICollectionViewScrollPosition not working

自闭症网瘾萝莉.ら 提交于 2021-01-27 12:42:53
问题 i have a collectionview that i am trying to scroll programatically. the problem being that if the cell i want to scroll to is visible in the collection view it doesn't scroll it to the centre. so for the image below the lower cell is item 1. and it does not scroll to it but it will scroll past item 1 to item 2. i have been trying to use UICollectionVieScrollPosition.CenterVertically but this does not seem to work. self.collectionView?.scrollToItem(at: IndexPath(row: 1, section: 0), at:

UICollectionViewCompositionalLayout - center items in sections or groups

戏子无情 提交于 2021-01-07 02:46:41
问题 I set up a collection view and its layout with the new compositional stuff and it has been pretty cool, it seems to be very expandable but I can't find a way to make items centered in the collection, which is IMO a basic feature that one would imagine being supported.. What I have is: Accomplished with this code: UICollectionViewCompositionalLayout { section, env in let tagDefaultSize = CGSize(width: 100, height: 40) let item = NSCollectionLayoutItem( layoutSize: NSCollectionLayoutSize

diffable data source section header blinks during update

我与影子孤独终老i 提交于 2021-01-05 13:19:37
问题 I'm currently facing the issue, that when applying a new snapshot to my current data source, that the header, footer and decoration views are not part of the collection view's subviews, which can be noticed as a weird flicker. Did anyone face that issue before? I update the data source via: var snapshot = NSDiffableDataSourceSnapshot<Section, Item>() snapshot.appendSections(Sections.allCases) items.forEach { snapshot.appendItems([$0], toSection: ItemSectionMapper.getSection(for: $0)) } self

diffable data source section header blinks during update

社会主义新天地 提交于 2021-01-05 13:18:47
问题 I'm currently facing the issue, that when applying a new snapshot to my current data source, that the header, footer and decoration views are not part of the collection view's subviews, which can be noticed as a weird flicker. Did anyone face that issue before? I update the data source via: var snapshot = NSDiffableDataSourceSnapshot<Section, Item>() snapshot.appendSections(Sections.allCases) items.forEach { snapshot.appendItems([$0], toSection: ItemSectionMapper.getSection(for: $0)) } self

UICollectionView Drag and Drop Folder Creation

自闭症网瘾萝莉.ら 提交于 2020-12-31 05:07:46
问题 I'm using UICollectionView to create a gallery app for iOS. I'd like for users to be able to drag and drop images to reorder the gallery and to create folders (similar to the home screen on the iPhone). I found the following tutorial to implement drag and drop reordering. However, I'm having an trouble figuring out where to start on the folder creation. What I'd like to do is implement the following scenarios: When an image is dragged around, it does not automatically reorder other images in