uicollectionviewcell

UIImageView in custom UICollectionViewCell returning nil all the time

梦想的初衷 提交于 2019-11-29 01:56:27
问题 OK in my story board I have made a UICollectionView with 3 cells. One of the cells I made a custom class for that obviously extends the UICollectionViewCell: And I registered the class in my ViewDiDApear: [self.collectionView registerClass:[DeviceImageCell class] forCellWithReuseIdentifier:@"Cell1"]; Also I have added an imageView to that specific cell and an outlet for that imageView in my custom class. Problem occurs when I make my custom cell it forgets everything that was set in my

Defining UICollectionViewCell with nib

六月ゝ 毕业季﹏ 提交于 2019-11-29 01:34:25
If I understand correctly, the content of a UICollectionViewCell should go inside its contentView property and the background into backgroundView . Yet, when I drag a UICollectionViewCell to Interface Builder there is no mention of contentView or backgroundView . If I add subviews, those will have the whole cell as its parent, not contentView or backgroundView . What is the right way of defining a UICollectionViewCell with IB, then? "If I add subviews, those will have the whole cell as its parent, not contentView" This is not true. If you drag in a UICollectionViewCell, and add UI elements to

Achieve button click in UICollectionView

冷暖自知 提交于 2019-11-29 00:28:31
Is there a way I can get the button click event from a button inside a UICollectionViewCell ? I used a nib to populate the collection view, the cell has the button but its action is not getting called. I think the problem is with the delegate being called. How can I fix this? How I created : Added an empty nib, created a collection view cell Added a .h and .m file and made the cell nib's files owner as the class created Wrote an action in the class. Connected the button to the action Is there a way I can get the action? What am I doing wrong? bloque13 Add the button action like this: -

Swipe Animation for remove Cell in UICollectionView - Swift 2.0

杀马特。学长 韩版系。学妹 提交于 2019-11-28 23:20:34
问题 I created an app with UICollectionView like this image: Added two gestures: The first (up) will erase the cell. The second (down) will update the cell (take new data of CoreData). The functions work fine, but there's no animation. iOS has a very cool animation dragging the cell up and the cell disappears. I am a beginner in animations swift, so I'm a little lost when it. My question is: How can I add an animation that takes up the entire cell? I read some answers on the site, but all in

Copy Callout in UICollectionView

扶醉桌前 提交于 2019-11-28 21:53:29
I have a UICollectionView with UIImageView in each cell, now I want to add Copy Callout, like in Photos.app: I saw this method in the UICollectionViewDelegate: - (BOOL)collectionView:(UICollectionView *)collectionView shouldShowMenuForItemAtIndexPath:(NSIndexPath *)indexPath { return YES; } After few additional minutes of research I found UIMenuController Class, as I understood, I must to work with it to get the Menu, but anyway, I think that there must to be more simple way then creating UIGestureRecognizer, and creating, positioning etc. my UIMenu. Am I on the right track? How could you

UICollectionViewCell with UIScrollView cancels didSelectItemAtIndexPath

自作多情 提交于 2019-11-28 21:23:35
I have a UICollectionView that horizontally scrolls to show one UICollectionViewCell at a time. Each UICollectionViewCell the has a vertically scrolling UIScrollView as subview for scrolling the contents of the cell. It is only 90 % or so of the inner part of the UICollectionViewCell that is covered by the UIScrollView - i.e. the outer frame of the cell is not covered by this. It turns out that the part of the UICollectionViewCell that is covered by the UIScrollView cancels the UICollectionView delegate didSelectItemAtIndexPath . Thus when a simple tap happens within the UIScrollView this

UICollectionView, simply fit cell to width?

馋奶兔 提交于 2019-11-28 20:11:57
Here's a simple UICollectionView in yellow The red arrow sets the width of the cell. (TBC: clicking on the pink cell: for 'size' select 'Default', then what you set at the red arrow becomes the size of the cell.) Example, for an upright iPhone set width to 320. But this seems crazy ... surely I can set the cell width based on the width of the UICollectionView ? There's no problem autosizing the view itself .. That works fine. But it seems crazy that I can't set the width of the CELL to be "same as the view". It seems hard to believe one has to set it manually, in code? TBC In other words, as

Expandable UICollectionViewCell

只愿长相守 提交于 2019-11-28 19:58:59
I'm trying to program an expandable UICollectionViewCell. If the user presses the topbutton, the cell should expand to a different height and reveal the underlying content. My first implementation features a custom UICollectionViewCell, which can be expanded by clicking the topbutton, but the collectionview does not expand too. Atm. the cell is the last one in the collectionview and just by swiping down enough, you can see the expanded content. If you stop touching, the scrollview jumps up and nothing of the expanded cell could be seen. Here's my code: import Foundation import UIKit class

How to create UICollectionViewCell programmatically

守給你的承諾、 提交于 2019-11-28 19:43:47
问题 I'm trying to create UICollectionView programatically. I need to add labels inside the cells, so I Created CollectionViewCell class. This is the class: import UIKit class MyCollectionViewCell: UICollectionViewCell { override init(frame: CGRect) { super.init(frame: frame) } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } } And this is the collectionView implementation class: import UIKit class TwoViewController: UIViewController,

Creating a horizontal scrolling collectionview in Swift

若如初见. 提交于 2019-11-28 18:59:57
How can I easily make a horizontal scrolling collectionView that fills up Cells going across the rows rather than down the columns? I want there to 5 columns and 3 rows but when there is more than 15 items I want it to scroll to the next page. I'm having alot of trouble getting this going. Option 1 - Recommended Use custom layouts for your collection view. This is the right way to do this and it gives you a lot of control over how you want your cells to fill the collection view. Here is a UICollectionView Custom Layout Tutorial from "raywenderlich" Option 2 This is more like a hackish way of