uicollectionview

UICollectionView autosize and dynamic number of rows

北慕城南 提交于 2020-02-20 08:18:45
问题 I am trying to do something like this: Basically, I am using a UICollectionView and the cells (3 diferent .xib ). So far, it works. The thing I want to do is: Set a autoheight If rotate, add 1 row to the UIColectionView 2.1 If tablet, on portrait will have 2 rows and landscape 3 rows. (which basically is the same of point 2, only adding 1 row. I have something like this: extension ViewController { override func viewWillTransition(to size: CGSize, with coordinator:

How to show view controller on selecting row cell of tableView(as a collection view cell)?

杀马特。学长 韩版系。学妹 提交于 2020-02-06 07:54:00
问题 I have the Main View Controller which has a collection view with its collection view cells each initialized as a tableView to serve multiple rows inside of that collection view cell. If you're getting confused, below is the snapshot of the current state. The problem is when I try to tap a tableView row cell to open another view controller, It fails and a selected state of table view cell is shown. Here is the snapshot. //HomeCollectionViewCell.swift class HomeCollectionViewCell:

iOS SIGABRT on dequeueReusableCellWithReuseIdentifier [duplicate]

别来无恙 提交于 2020-02-06 02:57:06
问题 This question already has answers here : UICollectionView registerClass: forCellWithReuseIdentifier method breaks UICollectionView (2 answers) Closed 6 years ago . I'm trying to get a UICollectionView working in my application and for some reason I keep getting a sigabrt. The error I am getting is * Assertion failure in -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:] I have googled around, and it seems like most of the time this is related to the neglecting to

UICollectionView and UIView into UIScrollView

|▌冷眼眸甩不掉的悲伤 提交于 2020-02-05 08:41:06
问题 I need to know how to do to embed a UICollectionView and a UIView within a UIScrollView, but that everything moves with the scroll of UIScrollview. the layout is something like the following image: 回答1: Why don't you use the view as the collectionView 's section supplementary view (see docs)? It will become part of the collectionView thus scrolling of the collectionView will handle also the view itself. 回答2: 1- Drag a UIScrollview to your vc give it leading , trailing , top and bottom

Download Images from a server to display on the CollectionView

微笑、不失礼 提交于 2020-02-03 05:45:08
问题 I am working on a product application where user could sell/buy. This application is based on collection view. Collection view has collection cell where it displays product image thumbnail. The following code gets products images from the server and it waits to download all images and then display them in the cells. The following code works but user is waiting 10-20 seconds to see all products. Is there a better way to handle ? - (void)viewDidLoad { [super viewDidLoad]; dispatch_queue_t queue

What's wrong with register(_:forCellWithReuseIdentifier:) on UICollectionView?

霸气de小男生 提交于 2020-02-02 02:43:05
问题 I'm working with an UICollectionView . As dequeueReusableCell(withReuseIdentifier:for:) expects You must register a class or nib file using the register(_:forCellWithReuseIdentifier:) method before calling this method , I added a line in my viewDidLoad func as self.collectionView!.register(PhotoCollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier) Now when I'm using the cell for dequeuing and configuring, I'm getting error and app crashes. fatal error: unexpectedly found nil

UICollectionView cellForItemAt indexPath is skipping row indexes in iOS 10

萝らか妹 提交于 2020-02-01 06:20:31
问题 I have UICollectionView with horizontal scrolling and paging. When I scroll to next or previous page for the first time or change scrolling direction from left to right, value of indexPath.row in cellForItemAtIndexPath is changing by 3 not 1. Then it works properly. CollectionView works without problems in iOS 9. The problem occurs just in iOS 10. Thanks. 回答1: Problem was with new prefetching feature of UICollectionView. Disabling of prefetching solved my problem. if #available(iOS 10.0, *)

Get Camera Roll photos to a Custom Collection View

限于喜欢 提交于 2020-02-01 05:38:27
问题 I have an Custom Collection View with Cells. Here is my CollectionView code. - (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath; { Cell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"MY_CELL" forIndexPath:indexPath]; return cell; } I want to get images from Camera Roll & display in these cells. How can I get Camera Roll images to view in this Cell? Should I use an array to store names of the images & then show them in the Cell

UICollectionView Cell with Image, change Background with click

守給你的承諾、 提交于 2020-01-29 17:55:11
问题 I have a UICollectionView with Custom CollectionView Cells . On each Cell there is a Image on it, which is as big as the whole Cell. Now i want to highlight the Cell when the User touches the Cell. First i tried it with the following delegate Methods : - (void)collectionView:(UICollectionView *)collectionView didHighlightItemAtIndexPath:(NSIndexPath *)indexPath { UICollectionViewCell* cell = [self.collectionView cellForItemAtIndexPath:indexPath]; cell.contentView.backgroundColor = [UIColor

ios UITableView行内嵌横向UICollectionView

北城余情 提交于 2020-01-25 18:44:32
ios UITableView行内嵌横向UICollectionView 1.在要添加CollectionView的行类添加UICollectionViewDelegate代理,并添加CollectionView的输出口 @interface XMWorkSpaceFristTableViewCell : UITableViewCell < UICollectionViewDelegate , UICollectionViewDataSource > @property ( weak , nonatomic ) IBOutlet UICollectionView * workspaceCollectionView ; @end 2.在这个TableViewCell.m里添加代理方法 - ( NSInteger ) numberOfSectionsInCollectionView : ( UICollectionView * ) collectionView { return 1 ; } // 设置cell大小 itemSize:可以给每一个cell指定不同的尺寸 - ( CGSize ) collectionView : ( UICollectionView * ) collectionView layout : ( UICollectionViewLayout * )