uicollectionviewcell

How to access IBOutlets of a UICollectionViewCell from a UIViewController?

ぐ巨炮叔叔 提交于 2019-12-11 04:16:34
问题 I implemented a UICollectionView inside a UIViewController. The header cell is created in a separate.xib file and it is implemented in a separate .h and .m files with the IBOutlets and IBActions. The rest of the cells are implemented in the same UIVIewController (The reason is because I added this Parallax effect). I would like to modify the info of the IBoutlets (labels and buttons) that are in the header cell (CSCellUser.h) from the viewcontroller (RankingViewController) which containts the

Inline property instantiation not working for generic UICollectionViewCell subclasses

蓝咒 提交于 2019-12-11 04:12:46
问题 If I define a UICollectionViewCell subclass: class TestCell<T>: UICollectionViewCell { var float: CGFloat? = 3 var string = "abc" } Register it: collectionView.registerClass(TestCell<String>.self, forCellWithReuseIdentifier: "Test") Then use it: collectionView.dequeueReusableCellWithReuseIdentifier("Test", forIndexPath: indexPath) as! TestCell<String> I notice strange behavior with the properties that should have been initialized. float == Optional(0.0) string == "" Why is this happening and

Subclassing a custom collection view cell created from a nib

自闭症网瘾萝莉.ら 提交于 2019-12-11 03:19:58
问题 I am struggling to figure out how to subclass a custom collection view cell that was created with a nib. Here is my setup: I have a custom collection view cell that is the superclass for all other collection view cells in my app, this view was created with a nib file. Now I want to subclass the custom collection view cell, and add more things again with a nib file. How do I subclass a cell created with a nib file? **I need to subclass a nib file and add to it with a nib file.***** Thank you :

How can I calculate the size of a UICollectionViewCell loaded from a xib with autolayout aspect ratio constraints?

心已入冬 提交于 2019-12-11 03:19:18
问题 I have a UICollectionViewCell that is loaded from a xib and stored in a property to help with calculating cell sizes for my collection view. The collection view always has only one column, so the cells vary in their widths based on the phone the user has (iphone 5/6/6+). The xib has an image view with an aspect ratio that must remain constant for all phone sizes. The problem I run into stems from this configuration. I cannot seem to make the cell size the way I want based on a fixed width. My

Button inside CollectionView not clickable

时光怂恿深爱的人放手 提交于 2019-12-11 03:11:19
问题 I have a button in a custom cell of a collectionview. The collectionview is on a scrollview. For some reason, I am not able to click on the button. I've checked that all my elements have User Interaction enabled. Here is my layout of the collection (I've hidden some sensitive data) Here is my custom collection view cell: class MyCollectionViewCell: UICollectionViewCell { @IBOutlet weak var nameLabel: UILabel! @IBOutlet weak var connectButton: UIButton! var onConnectTap: (MyCollectionViewCell)

Cell Label text overlapping in cells

♀尐吖头ヾ 提交于 2019-12-11 03:05:00
问题 I am attempting to add a UILabel to my collectionViewCell . However, after a few cell text begins to overlap with data from the cells before. UPDATE : This only seems to happen on my phone (iphone 5), but not on the simulator (2013 macbook air). As seen here: I am implementing the whole view programmatically. The issue doesn't seem to be with any of the elements of the collectionview , so I would assume the problem applies to table views as well. I am not sure if I am missing something along

Unable to set width of UICollectionViewCell with AutoLayout

夙愿已清 提交于 2019-12-11 02:58:57
问题 I have a Collection View with cells of dynamic height (based on a possibly multiline label and a textview inside), which adapts in height perfectly when I span it over multiple lines. However, when the text is just one word or it doesn't cover the entire screen width, the cell is just as wide as needed to be, resulting in cells next to each other instead of underneath each other. Take a look at the result with different lengths of text inside the textview. However, I want the cells to be

In SWIFT, dynamic height for UItextview in UIcollectionView

守給你的承諾、 提交于 2019-12-11 02:57:32
问题 I am using two collectionview. One for displaying story. Another for calendar. It will display last 15 days. I need left to right scroll, so content offset i used. Text I am receiving from parse, according to that text size, textview frame has been displayed. For story view, paging is enabled. So one by one story has been displayed. But, bottom, having date view, 4 dates displayed at a time. If I click 10th date, story view gets scroll to 10th story. But at that time, I textview is not

iOS - How to apply gradient color to UICollectionViewCell backgroundView?

こ雲淡風輕ζ 提交于 2019-12-11 02:56:08
问题 I have been able to apply the gradient I want to the backgroundView of my UICollectionViewCell. But every time I reload the cell, it applies again my gradient, accumulating all the gradient. First of all here is my method for the gradient : static func setGradientWhite(uiView: UIView) { let colorBottomWhite = UIColor(red:1.00, green:1.00, blue:1.00, alpha:0.30).cgColor let colorTopWhite = UIColor(red:1.00, green:1.00, blue:1.00, alpha:0).cgColor let gradientLayer = CAGradientLayer()

Use custom init method when programmatically creating a uicollectionview

╄→гoц情女王★ 提交于 2019-12-11 02:51:47
问题 Due to the limitations of Storyboard I am creating a UICollectionView programmatically. This is working all fine and when I want to add a UICollectionViewCell I do the following: [collectionView registerClass:[Cell class] forCellWithReuseIdentifier:@"ID"]; What I was wondering is how can I use a custom init method from the class "Cell", because I can't do something like the following: [collectionView registerClass:[[Cell class]init_custom]forCellWithReuseIdentifier:@"ID"]; Question: How can I