uicollectionview

Preventing “wrapping” of items in UICollectionView

拟墨画扇 提交于 2019-12-21 04:34:04
问题 I need a UICollectionView to display a grid that is potentially larger than the visible frame in both width and height, while maintaining row and column integrity. The default UICollectionViewFlowLayout allows sections to scroll off-screen, but it wraps items within a section to keep them all on-screen, which screws up my grid. Recognizing that UICollectionView is a subclass of UIScrollView , I tried just manually setting the collection view's content size property in viewDidLoad: self

Swift, Change width of UICollectionViewCell and UILabel(inside the cell) programmatically

那年仲夏 提交于 2019-12-21 04:13:28
问题 I've set the width of a cell(UICollectionViewCell) to be equal to the width of the UICollectionView and I'm trying to do exactly the same thing with the UILabel that is included inside that cell. I think the code below explains exactly what I'm trying to achieve. So i've read some question here in SO and also a couple of tutorials but I'm still not sure how I can achieve this. In a couple of questions it was saying about using collectionViewLayout but I'm really struggling on how to use it

How to display ads within a collection view

会有一股神秘感。 提交于 2019-12-21 04:10:53
问题 I'm trying to add some banner ads randomly inside my collectionView. Each collectionView cell would be a basic image (black square here to make things easier) populated dynamically from an array (let's say it's a really long array and call it "longDataArray") that I would get from the web. I could manage to add some banner ads to my collectionView but the problem is that it's breaking the order of my longDataArray. For example, just for testing when I'm adding an ad banner at indexPath 6,

UICollectionView: different size items is not calculated on reused items

廉价感情. 提交于 2019-12-21 03:42:26
问题 I have a collection view with varied item sizes which i declare in - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { FeedItem *item = [_imagesLinkArray objectAtIndex:indexPath.row]; return CGSizeMake(250, 200*item.sizeFactor); } When the cell is being reused in collectionView:cellForItemAtIndexPath: the item is being rendered with the reuesed item size and not the one specified in

Autoresize UICollectionView height to adjust to its content size

怎甘沉沦 提交于 2019-12-21 03:28:05
问题 I have a UICollectionView, a button that creates a new cell in collection view. And I want UICollectionView to adjust it's size according to it's content size (when there are one or two cells then UICollectionView is short, if there are a lot of cell UICollectionView is big enough). I know how to get content size: collectionView.collectionViewLayout.collectionViewContentSize But I have no idea where to use this value. I would appreciate if somebody help me to figure out how to make

Is there a way to automatically scroll to the bottom of a UICollectionView

吃可爱长大的小学妹 提交于 2019-12-21 02:59:32
问题 So I'm currently working on a project that has a button that adds cells to a UICollectionView and then needs to automatically scroll to the last cell (i.e. the bottom of the UICollectionView). I've found the method scrollToItemAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UICollectionViewScrollPosition)scrollPosition animated:(BOOL)animated But now I'm getting stuck at trying to find the indexPath of the last object in the CollectionView. The problem seems to lie in that I've been

Swift: UICollectionViewCell didSelectItemAtIndexPath Change backgroundColor

雨燕双飞 提交于 2019-12-21 02:42:19
问题 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

How to reload only data section of UICollectionView?

心不动则不痛 提交于 2019-12-21 02:40:41
问题 I'm trying to reload only data section, not header or footer (supplementary view), of UICollectionView. When I use reloadData method, header and footer section also reloads, so that's what I want. I found the method reloadSections: , but I don't know why it doesn't work. Because my collection view only contains one section, so I tried using the method like this: [collectionViewController.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]]; But it makes runtime error when the

Issue with pagination in UICollectionView when orientation changes

无人久伴 提交于 2019-12-21 02:28:10
问题 I'm preparing a GridView with all orientation support (height & width resizing) and paging enabled. In my sample in have taken a 3*3 Grid and to show it like that I have added some dummy transparent cell at the last page. The issue is when I'm at last page and there I'm changing my orientation from landscape to portrait the pagination doesn't work. I have used this code in willRotateToInterfaceOrientation : CGPoint scrollTo = CGPointMake(self.frame.size.width * mPageControl.currentPage, 0);

UICollectionView cells resizing when deleting items with estimatedItemSize

点点圈 提交于 2019-12-21 01:25:10
问题 I have a simple project with a storyboard containing only a single a UICollectionViewController , built with Xcode 7.1.1 for iOS 9.1 class ViewController: UICollectionViewController { var values = ["tortile", "jetty", "tisane", "glaucia", "formic", "agile", "eider", "rooter", "nowhence", "hydrus", "outdo", "godsend", "tinkler", "lipscomb", "hamlet", "unbreeched", "fischer", "beastings", "bravely", "bosky", "ridgefield", "sunfast", "karol", "loudmouth", "liam", "zunyite", "kneepad", "ashburn",