uicollectionviewcell

Access a UICollectionView's parent UIViewController

你离开我真会死。 提交于 2019-11-30 14:04:04
My question is fairly straightforward. I have a UIViewController containing a UICollectionView. In initialising my cells, I add a gesture recogniser to each of them so that when you tap and hold it calls a function with a selector. This function then creates a UIAlertController which I want to present. (Basically, you hold a cell, it asks you if you want to delete it and if you say yes it eliminates it from the CollectionView) The problem is that I can't present a UIAlertController from my UICollectionView because it isn't a ViewController. I want to programmatically get the UIViewController

UICollectionView 3 column grid, 1px space?? (image included)

放肆的年华 提交于 2019-11-30 11:19:56
I have setup a UICollectionView with a FlowLayout that leaves no space in between cells in either the vertical or horizontal directions. I have everything working, yet there is an odd 1px space between the 2nd and 3rd column and I have no idea why!? I have verified the 1px gap shows up both in iOS simulator and on a real device. Has anybody experienced this? My UIViewController is a delegate/datasource of the following: class MyViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout I have implemented the necessary functions to

Deleting cells from UICollectionView via NSNotification

北城以北 提交于 2019-11-30 09:20:28
I have a simple UICollectionView based app - one UICollectionView and a NSMutableArray based data model for simplicity. I can delete cells with no problem via the didSelectItemAtIndexPath: delegate method: -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ [self.data removeObjectAtIndex:[indexPath row]]; [self.collectionView deleteItemsAtIndexPaths:@[indexPath]]; } However, I'm trying to add a delete option via a UIMenuController in a UICollectionViewCell subclass which is triggered via a UILongPressGestureRecognizer which all works fine

How to determine when a custom UICollectionViewCell is 100% on the screen

混江龙づ霸主 提交于 2019-11-30 08:57:26
From the diagram above I have UICollectionView with 4 custom cells. At any time 2 or three cells can be on the screen. How can I tell when "cell 1" or "cell 2" is 100% on the screen? Both collectionView.visibleCells collectionView.indexPathsForVisibleItems return arrays and doesn't tell you if what cell 100% on the screen. In the case of the image, the following will be display on didSelectItemAt collectionView.visibleCells [<Shot_On_Goal.MainCollectionViewCell: 0x101f525c0; baseClass = UICollectionViewCell; frame = (190 7.66667; 454 350); clipsToBounds = YES; opaque = NO; layer = <CALayer:

Trying to override “selected” in UICollectionViewCell Swift for custom selection state

夙愿已清 提交于 2019-11-30 08:05:06
I am trying to implement a custom selection style for my cells in a UICollectionView. Even though it is easily possible to do this manually in the didSelect and didDeSelect methods I would like to achieve this by manipulating the "selected" variable in UICollectionViewCell. I have this code for it: override var selected: Bool { get { return super.selected } set { if newValue { self.imageView.alpha = 0.5 println("selected") } else if newValue == false { self.imageView.alpha = 1.0 println("deselected") } } } Now, when I select a cell, the cell gets highlighted but "selected" gets printed twice

How to add a delete button to Collection View Cell in Swift?

浪尽此生 提交于 2019-11-30 07:37:49
Right now I have a list of scrolling usernames using a Collection View of buttons. But I’d like to add overlapping delete buttons to each row. They'd need to be attached to the name buttons and scroll with them. How can I add these buttons to my CollectionView? (Also I'd like to skip the delete button on the first row for obvious reasons) Current Code: //Add the cells to collection func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { let cell: UsernameCollectionViewCell = collectionView

UICollectionViewCell with UIScrollView cancels didSelectItemAtIndexPath

旧时模样 提交于 2019-11-30 06:47:18
问题 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

Scrollbar incorrectly appears underneath UICollectionView section header

时光怂恿深爱的人放手 提交于 2019-11-30 05:46:43
For some reason my scrollbar always appears underneath the collection view section header. Any help is greatly appreciated! I found a workaround. This issue is that the zPosition of the header view is being set by the collection view incorrectly. To fix this, we will always ensure that the zPosition is our desired value. Create a CALayer subclass which prevents the zPosition from being anything other than 0. class CustomLayer: CALayer { override var zPosition: CGFloat { get { return 0 } set {} } } Then set the layer class of your collection view header to this new subclass. class MyHeaderView:

UICollectionView estimatedItemSize - last cell is not aligned

非 Y 不嫁゛ 提交于 2019-11-30 05:43:23
I want to make a usual horizontalScrolling flowLayout UICollectionView with estimatedItemSize and preferredLayoutAttributesFittingAttributes in cell. But there is something wrong with last cell. Any idea where is the issue? Project itself @implementation RowCollectionView - (instancetype) initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout { if (self = [super initWithFrame:frame collectionViewLayout:layout]) { [self configureRowCollectionView]; } return self; } - (void) awakeFromNib { [super awakeFromNib]; [self configureRowCollectionView]; } - (void)

UICollectionView within a UICollectionViewCell (Swift)

非 Y 不嫁゛ 提交于 2019-11-30 05:28:36
I'm trying to put a UICollectionView within each reusable UICollectionViewCell . The Ash Furrow method didn't work out too well for me, because using one UICollectionViewController class for the data source and delegate of two UICollectionViews does not work. My latest approach is to put the view of a UICollectionViewController inside each cell, as described in this question and this doc . However, when I go try to load the view, my app freezes. In the Xcode debug navigator, the CPU is at a constant 107% and the Memory approaches 1GB after a few seconds. In this example, I am trying to get a