uicollectionviewcell

Simple UICollectionView to show images behaves odd: Some Images are displayed correct, some at wrong position, some missing at all

爱⌒轻易说出口 提交于 2019-12-03 10:07:12
I want to show images in a grid on iPhone using a UICollectionView, showing 3 images a row. For a "dead simple test" (as I thought), I've added 15 JPG images to my project, so that they'll be in my bundle and I can load them simply via [UIImage imageNamed:...]. I think I've done everything correct (setting up & registering UICollectionViewCell subclass, use of UICollectionViewDataSource Protocol methods), however, the UICollectionView behaves very weird: It shows only a few of the images in the following pattern: First line shows image 1 & 3, second line is blank, next line like the first

How to refresh UICollectionViewCell in iOS 7?

一个人想着一个人 提交于 2019-12-03 09:40:59
问题 I am trying to develop my app in Xcode 5 and debug it under iOS 7 environment. I have a customized UICollectionViewLayoutAttributes. I plan to do something after long pressing on UICollectionViewCell, so I override the method in UICollectionViewCell.m - (void)applyLayoutAttributes:(MyUICollectionViewLayoutAttributes *)layoutAttributes { [super applyLayoutAttributes:layoutAttributes]; if ([(MyUICollectionViewLayoutAttributes *)layoutAttributes isActived]) { [self startShaking]; } else { [self

How can I enable/disable section headers in UICollectionView programmatically?

好久不见. 提交于 2019-12-03 09:23:12
How can I enable/disable section headers in UICollectionView programmatically? It can be easily done easily done in Storyboard (checkbox), but how about doing it in code? spassas You can either use the collectionView:layout:referenceSizeForHeaderInSection: method of the UICollectionViewDelegateFlowLayout and return CGSizeMake(0,0) or set accordingly the headerReferenceSize of UICollectionViewFlowLayout . Edit: headerReferenceSize is actually the property that storyboard uses to show/hide the headers. I've added the relevant lines from the Storyboard file With section checkbox on :

How to delete an item from UICollectionView with indexpath.row

别说谁变了你拦得住时间么 提交于 2019-12-03 07:58:47
问题 I have a collection view,and I tried to delete a cell from collection view on didSelect method.I succeeded in that using the following method [colleVIew deleteItemsAtIndexPaths:[NSArray arrayWithObject:indexPath]]; But now I need to delete the item on button click from CollectionView Cell.Here I get only the indexpath.row. From this I am not able to delete the Item. I tried like this. -(void)remove:(int)i { NSLog(@"index path%d",i); [array removeObjectAtIndex:i]; NSIndexPath *indexPath =

Swift: UICollectionViewCell didSelectItemAtIndexPath Change backgroundColor

那年仲夏 提交于 2019-12-03 07:39:01
I'm easily able to change the background color of a cell in the CellForItemAtIndexPath method func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { cell.backgroundColor = UIColor.blackColor() } However, when I attempt to change the color in the DidSelectItemAtIndexPath it does not work. func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) { let cell: ButtonCollectionCell = collectionView.dequeueReusableCellWithReuseIdentifier("ButtonCell", forIndexPath: indexPath) as!

Swift: UICollectionView selecting cell indexPath issues

两盒软妹~` 提交于 2019-12-03 07:34:50
问题 I am trying to do a Collection View whereby someone selects a cell and for each selection it takes them to another View Controller that holds content of the selection. However I'm running into difficulties as once I apply this line of code to didSelectItemAtIndexPath ; self.performSegueWithIdentifer("showDetail", sender: self) and then run it in the Simulator the cell selection is working according the indexPath but its remembering the selections each time I select new cell . So for example

UICollectionView Cell Scroll to centre

前提是你 提交于 2019-12-03 07:26:56
问题 I am using UICollectionView in my UIViewController. My collectionview properties are set as below. Now I would like cell to be Centre on screen after scroll! Option 1: Option 2: What would I have to do achieve option 2? UPDATE: In the end I have used following code as scrolling with other answer is not smooth. - (CGPoint)targetContentOffsetForProposedContentOffset:(CGPoint)proposedContentOffset withScrollingVelocity:(CGPoint)velocity { CGFloat offsetAdjustment = MAXFLOAT; CGFloat

Populating UICollectionView in reverse order

余生颓废 提交于 2019-12-03 07:18:00
I would like to populate UICollectionView in reverse order so that the last item of the UICollectionView fills first and then the second last and so on. Actually I'm applying animation and items are showing up one by one. Therefore, I want the last item to show up first. I'm assuming you are using UICollectionViewFlawLayout, and this doesn't have logic to do that, it only works in a TOP-LEFT BOTTOM-RIGHT order. To do that you have to build your own layout, which you can do creating a new object that inherits from UICollectionViewLayout. It seems like a lot of work but is not really that much,

UICollectionView in a UICollectionViewCell

最后都变了- 提交于 2019-12-03 06:36:03
I am interested in having a collectionview as a part of a collection view cell but for some reason cannot figure out how this would be done. Where would I implement the necessary methods for the cells collectionview? There's an article that Ash Furrow wrote that explains how to put an UICollectionView inside an UITableViewCell . It's basically the same idea when using it inside an UICollectionViewCell . Everything is done programatically. No storyboards. I added a UICollectionView inside my UICollectionViewCell. I also show how to add again a UICollectionViewCell inside the created

UICollection View Adjust Cell Size for Screen Size

此生再无相见时 提交于 2019-12-03 06:32:45
问题 Currently i have a collection view which takes up most of my screen at the 3.5 inch screen size.The collection view is 51 pixels from the top and 20 pixels from the bottom of the screen. I am using the cells with UIPageControl to create a paged layout, with one cell per page. When switching to the 4 inch size, using constraints i can get the collection view to expand into the new space (maintaining the 51 pixels from the top and 20 from bottom), but the cell size stays the same, so now there