uicollectionview

How to change background color of a whole section in UICollectionView?

谁说我不能喝 提交于 2019-12-29 03:28:09
问题 In UICollectionView, I want to give the whole section a uniform background color, instead of for a single cell or for the whole collection view. I don't see any delegate method to do that, any suggestions? 回答1: The idea is to override UICollectionViewLayoutAttributes to add a color attribute. And then override UICollectionReusableView apply the color to the view background. https://github.com/strawberrycode/SCSectionBackground 回答2: This is a great tutorial for changing UICollectionView

How to determine when all images have been downloaded from a set in Swift?

南笙酒味 提交于 2019-12-29 02:00:08
问题 I'm using the PinRemoteImage library to download images that populate a collectionView . I want to update the cell height dynamically based on the image height, so I need to know when all my images are downloaded so that I can reload/invalidate my collectionViewLayout . What's the best way to determine when there are no more images left to download? override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { let cell

UICollectionView Performing Updates using performBatchUpdates

邮差的信 提交于 2019-12-28 08:08:49
问题 I have a UICollectionView which I am trying to insert items into it dynamically/with animation. So I have some function that downloads images asynchronously and would like to insert the items in batches. Once I have my data, I would like to do the following: [self.collectionView performBatchUpdates:^{ for (UIImage *image in images) { [self.collectionView insertItemsAtIndexPaths:****] } } completion:nil]; Now in place of the *** , I should be passing an array of NSIndexPaths , which should

Hide NavigationBar when scrolling tableView in CollectionView?

余生长醉 提交于 2019-12-28 05:40:07
问题 I have collectionViewController and collectionViewCell include TableView.CollectionView is horizontal layout.I want hide navigationbar when scroll the tableView. Is there any idea about that. 回答1: Since iOS 8 you can just use self.navigationController?.hidesBarsOnSwipe = true This requires of course that your ViewController is embedded in a NavigationController. All child VC of the NavigationController will inherit this behaviour, so you might want to enable/disable it in viewWillAppear . You

UICellView cell layout in swift

爱⌒轻易说出口 提交于 2019-12-28 04:33:07
问题 I am trying to use a UICollectionView to create a grid which a user can set to be x cells by y cells (entered in text boxes), while still occupying the same width on the screen. I have been able to create a grid view which contains the correct number of cells, but these aren't in the correct layout yet, i.e. entering 5 by 7 will give 35 cells but not in a 5 cell by 7 cell layout. This is the code I have so far. MyCollectionViewCell.swift import UIKit class MyCollectionViewCell:

Creating slow scrolling to indexPath in UICollectionView

送分小仙女□ 提交于 2019-12-28 04:01:10
问题 I'm working on a project where I'm using a UICollectionView to create an 'image ticker' where I'm advertising a series of logos. The collectionView is one item high and twelve items long, and shows two to three items at a time (depending on size of the logos visible). I would like to make a slow automatic scrolling animation from the first item to the last, and then repeat. Has anyone been able to make this work? I can get the scrolling working using [myCollection scrollToItemAtIndexPath:

UIRefreshControl on UICollectionView only works if the collection fills the height of the container

泪湿孤枕 提交于 2019-12-28 03:18:12
问题 I'm trying to add a UIRefreshControl to a UICollectionView , but the problem is that the refresh control does not appear unless the collection view fills up the height of its parent container. In other words, unless the collection view is long enough to require scrolling, it cannot be pulled down to reveal the refresh control view. As soon as the collection exceeds the height of its parent container, it is pulled down and reveals the refresh view. I have set up a quick iOS project with just a

Set UICollectionViewCell width programmatically to UICollectionView width

偶尔善良 提交于 2019-12-26 03:47:00
问题 In the collection view how do we set the cell size of width and height based on the overall collection view. it will set for small to large devices (for example : if the collection view overall width = 375.0000 and we divide into 3. so it will set for the all the large and small devices). - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"SETTING SIZE FOR ITEM AT INDEX %d",

Nothing Occurring with ScrollToItem in UICollectionView

无人久伴 提交于 2019-12-25 18:29:13
问题 I have two collection views within a ViewController. One Collection view represents the tab bar at the top, the other represents pages on the bottom half of the screen. I have the second UICollectionView (on the bottom half) within a custom UIView (loading from another class). My objective is to have when I click on the tab bar, to move the bottom collectionView accordingly, with regards to the scrollToIndex. My issue is that when I click on the tab bar at the top, and call the function that

parsing complex JSON to UITableView And UICollectionView

帅比萌擦擦* 提交于 2019-12-25 17:43:47
问题 i am creating swift app and i want to parse JSON but first let me show you my UI i have One UITableview inside tableview cell i have UICollectionView and below is the screen shot of my UserInterface And here is my JSON which i have to parse { "jigyasa_category_list": [ { "status": "1", "updated_date": "2019-11-18 17:02:37", "created_date": "2019-08-28 16:32:22", "jigyasa_category_image_id": "4", "jigyasa_sanskrit": "jigyasa cate sanskrit 2", "jig_cate_id": "7", "jigyasa": [ { "image1": "http: