uicollectionviewcell

Autolayout is not resizing Uicollectionviewcell items when animating between layouts

邮差的信 提交于 2019-12-03 21:34:02
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. It seems as if I need to somehow control the auto layout constraints so they animate with the set layout

Expanding UICollectionView and its cell when tapped

℡╲_俬逩灬. 提交于 2019-12-03 20:46:44
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 = UISearchBar() override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the

How do I use UILongPressGestureRecognizer with a UICollectionViewCell in Swift?

两盒软妹~` 提交于 2019-12-03 18:26:10
问题 I would like to figure out how to println the indexPath of a UICollectionViewCell when I long press on a cell. How can I do that in Swift? I have looked all over for an example of how to do this; can't find one in Swift. 回答1: First you your view controller need to be UIGestureRecognizerDelegate . Then add a UILongPressGestureRecognizer to your collectionView in your viewcontroller's viewDidLoad() method class ViewController: UIViewController, UIGestureRecognizerDelegate { override func

Can´t add items to UICollectionView inside UIView xib

Deadly 提交于 2019-12-03 17:07:00
问题 Objective I wanna place my (BusinessViewTableHeader: UIView) as tableView header: tableView.tableHeaderView = BusinessViewTableHeader.instanceFromNib() as! BusinessViewTableHeader Inside BusinessViewTableHeader there is a UICollectionView which are supposed to display images when swiped, much like the Tinder app. This is my UIView subclass: class BusinessViewTableHeader: UIView { @IBOutlet var collectionView: UICollectionView! override func awakeFromNib() { super.awakeFromNib() self

collectionViewContentSize() vs contentSize

六月ゝ 毕业季﹏ 提交于 2019-12-03 17:01:01
What is the difference between collectionViewController.collectionViewLayout.collectionViewContentSize() and collectionViewController.collectionView.contentSize ? What do you prefer to use? collectionViewContentSize() is a method you can override (in the layout) to generate the size dynamically. contentSize is a property of collectionView that is going to be used if there is no such override. It is similar to a UITableView 's rowHeight vs. the UITableViewDelegate 's heightForRowAtIndexPath() . Please also note (as mentioned in the comments) that " contentSize is a UIScrollView -inherited

UICollectionViewCell register class fails, but register nib works

删除回忆录丶 提交于 2019-12-03 16:45:57
问题 Creating a custom UICollectionViewCell for my UICollectionViewController , it works by registering the nib; however, fails to register by class. Using registerClass() - fails Registering by class seems correct - it builds, but throws an exception at runtime unwrapping optional elements from the UIView. Without referencing outlets, it runs; however, no cells appear within the collection view. collectionView?.registerClass(MyCollectionViewCell.self, forCellWithReuseIdentifier: "myCell") Clearly

UICollectionView with variable cell sizes

妖精的绣舞 提交于 2019-12-03 16:09:27
I'm struggling a little bit with the size for cells in UICollectionView. In android, you can easily "wrap" the size of the cell. Just like in iOS, you have a function call 'GetCell' and you decide how big it will be. The difference in iOS is that in the "getCell" function (of UICollectionViewController) it seems you can't choose the size of the cell (or the contentview). If I change the size, it will ignore it and use anyway the general 'ItemSize' of the CollectionView (which is the same for all cells). This sometimes results in Views which are not very beautiful. For example, if I have a

Swift - Call self.navigationController into custom cell class

我是研究僧i 提交于 2019-12-03 16:06:24
Swift: I have UICollectionViewController with another file/class UICollectionViewCell The goal is to push UIViewController from my custom cell class. something like this: self.navigationController?.pushViewController(vc, animated: true) I have no problems to implement push from didSelectItemAtIndexPath in UICollectionViewController but i want to do this from custom cell class registered into my UICollectionViewController . When i try to push view from custom cell class unfortunately i don't have access self.navigationController Also i want to do this 100% programmatically. I don't use

How to add uibutton action in a collection view cell?

时光总嘲笑我的痴心妄想 提交于 2019-12-03 15:15:48
So I have this collection view with cells containing an edit button, located on the upper right corner. How do I wire up an action into it? I tried adding cell.editbutton.addTarget in collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell But it doesn't detect the touchUpInside Event. iDeveloper May be needful for you- Write this code in cellForItemAtIndexPath Swift 2.X let editButton = UIButton(frame: CGRectMake(0, 20, 40,40)) editButton.setImage(UIImage(named: "editButton.png"), forState: UIControlState.Normal) editButton.addTarget(self

prevent uicollectionview section starting on new line [duplicate]

依然范特西╮ 提交于 2019-12-03 15:06:55
This question already has answers here : UICollectionView remove section breaks with UICollectionViewFlowLayout (2 answers) I'm using a flow layout on uicollectionview. It all looks great except it seems to start another section on another line. This seems like a sensible default but how do I override this and make the sections flow seamlessly on the same line as if no new section began? Thanks! There is a library I found which has this as one of its features RDHCollectionViewGridLayout https://github.com/rhodgkins/RDHCollectionViewGridLayout 来源: https://stackoverflow.com/questions/23820978