uicollectionviewcell

Deleting cells from UICollectionView via NSNotification

笑着哭i 提交于 2019-11-29 14:08:46
问题 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

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

梦想与她 提交于 2019-11-29 12:58:44
问题 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 =

In a UICollectionView, the cells will not sit on the bottom

落爺英雄遲暮 提交于 2019-11-29 11:36:48
Note it turned out it was a simple mistake the cells would not "sit on the bottom". However, it's an interesting question: "how to move the cells up and down." Below a brute force solution: writing your own flow layout. I was amazed that the only way to do it is entirely subclass UICollectionViewFlowLayout and write some tricky code in layoutAttributesForElementsInRect . It's possible this will help someone in the future, as there is very little example code for layoutAttributesForElementsInRect around. Hope it helps. -- It turns out the reason my cells would not sit on the bottom was that I

Animate uicollectionview cells on selection

痞子三分冷 提交于 2019-11-29 11:30:22
I have created a customlayout and set my cells position attribute in layoutAttributesForItemAtIndexPath like this attributes.center = CGPointMake((size.width/2 - 100) + 100, (size.height/2 - 150) +100); I would like to animate a cell when it is selected. replicating the kind of animations we get with the initialLayoutAttributesForAppearingItemAtIndexPath & finalLayoutAttributesForDisappearingItemAtIndexPath . I'd like to do this when a cell is selected and de-selected. so for instance: Cell A is in position 0,0 . Cell B is in position 50,100 . If I select cell B I'd like to animate it to 0,0 .

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

心已入冬 提交于 2019-11-29 10:22:29
问题 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) ->

UICollectionView cellForItemAtIndexPath is nil

蓝咒 提交于 2019-11-29 05:27:11
I have a function that updates existing UICollectionView. The UICollectionView is created, I can see it, but when I want to access its cells to update it, they are nil. -(void)finishExam{ for (int i = 0; i < [self.questionsOverviewCollection numberOfItemsInSection:0]; i++) { NSLog(@"self.questionsOverviewCollection - %@",self.questionsOverviewCollection); NSLog(@"cell - %@",[self.questionsOverviewCollection cellForItemAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]]); NSLog(@"overviewCell - %@",(OverviewCell*)[self.questionsOverviewCollection cellForItemAtIndexPath:[NSIndexPath

Scrollbar incorrectly appears underneath UICollectionView section header

假装没事ソ 提交于 2019-11-29 04:57:56
问题 For some reason my scrollbar always appears underneath the collection view section header. Any help is greatly appreciated! 回答1: 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 }

UICollectionView within a UICollectionViewCell (Swift)

谁说我不能喝 提交于 2019-11-29 04:03:03
问题 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

Large cells in a UICollectionView getting removed while the cell is still displayed

徘徊边缘 提交于 2019-11-29 02:27:17
问题 I have a UICollectionView that contains some large UICollectionViewCells . These cells are so large that they completely fill the UICollectionView bounds and extend off screen. The problem is that the large cells are removed from the UICollectionView and queued for reuse while they are still displayed, resulting in a blank view. If I continue scrolling on the blank UICollectionView area, eventually the final portion of the cell appears and the start of the next cell appears in exactly the

UICollectionView display 3 items per row

最后都变了- 提交于 2019-11-29 02:20:47
I have a UICollectionView created from storyboard, I want to have 3 items per row in the view. I managed to do that using the following: - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { return CGSizeMake(collectionView.frame.size.width/3.6 , (collectionView.frame.size.height-100)/2); } However, if i have 6 items, i got 2 rows with 3 items each. But when i have 4 items, it will display 2 rows with 2 items each. Is it possible to display them in 2 rows, the first with 3 items and