uicollectionviewdelegate

Serious bug for UICollectionViewFlowLayout: minimumInteritemSpacing and minimumLineSpacing in horizontal scrolling mode

时光毁灭记忆、已成空白 提交于 2019-12-05 02:49:11
问题 I am facing the following bug with UICollectionView in the horizontal scrolling mode ( iOS 8 , iOS 7 , the only ones I have tested). My question I would like to have your views on this bug and on how I could elegantly solve it. The setting up UICollectionViewFlowLayout * layout ; layout = [[UICollectionViewFlowLayout alloc] init] ; layout.scrollDirection = UICollectionViewScrollDirectionHorizontal ; layout.minimumInteritemSpacing = 5 ; layout.minimumLineSpacing = 100 ; The bug It's difficult

Adding UICollectionView inside UIView without Storyboards

眉间皱痕 提交于 2019-12-04 20:46:09
I have ViewController called myVC with UITablewView - myTable . What I want is to add some UIView as myTable's headerView from code . So inside viewDidLoad() method of myVC I added this code let topView = TopView() topView.frame.size.height = 100 topView.frame.size.width = myTable.frame.width myTable.tableHeaderView = featuredEventsView I also created file called TopView.swift that looks something like class TopView : UIView { override init(frame: CGRect) { super.init(frame: frame) self.backgroundColor = .red } required init?(coder aDecoder: NSCoder) {.....} } And it is working as it should. I

iOS流布局UICollectionView系列二——UICollectionView的代理方法

假装没事ソ 提交于 2019-12-02 09:10:36
iOS流布局UICollectionView系列二——UICollectionView的代理方法 一、引言 在上一篇博客中,介绍了最基本的UICollectionView的使用和其中我们常用的属性和方法,也介绍了瀑布流布局的过程与思路,这篇博客是上一篇的补充,来讨论关于UICollectionView的代理方法的使用。博客地址: UICollectionView的简介和简单使用: http://my.oschina.net/u/2340880/blog/522613 二、UICollectionViewDataSource协议 这个协议主要用于collectionView相关数据的处理,包含方法如下: 首先,有两个方法是我们必须实现的: 设置每个分区的Item个数 - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section; 设置返回每个item的属性 - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath; 下面的方法是可选实现的:

UICollectionViewLayout layoutAttributesForElementsInRect and layoutAttributesForItemAtIndexPath

我是研究僧i 提交于 2019-11-30 18:46:47
I'm implementing a custom flow layout. It has 2 main methods for overriding to determine placement of cells: layoutAttributesForElementsInRect and layoutAttributesForItemAtIndexPath . In my code, layoutAttributesForElementsInRect is called, but layoutAttributesForItemAtIndexPath isn't. What determines which gets called? Where does layoutAttributesForItemAtIndexPath get called? layoutAttributesForElementsInRect: doesn't necessarily call layoutAttributesForItemAtIndexPath: . In fact, if you subclass UICollectionViewFlowLayout , the flow layout will prepare the layout and cache the resulting

Change Background of UICollectionView Cell on Tap

冷暖自知 提交于 2019-11-28 05:18:37
I have a UICollectionView that I have created programmatically. I would like for the collection view to behave in the following way: 1. User touches cell 2. Cell background color changes 3. User releases touch 4. Cell background color changes This should be a quick color change that happens just before the selector related to the tap action is executed in which the viewcontroller containing the collection view is popped off the stack. I have been looking at this question: UICollectionView cell change background while tap in which there is the following summary of methods to use for this

UICollectionView: How to define a UICollectionViewLayout that supports horizontally and vertically scrolling?

荒凉一梦 提交于 2019-11-28 03:36:24
At the moment I'm trying to create an UICollectionView , that should display a simple excel-like-spreadsheet , with rows and columns . This should be an easy task with UICollectionViews , I believed. And I really would like to do the implementation in UICollectionView , not in any grid framework . But at the moment I'm hanging a little bit. What I've figured out is, that I unfortunately can't use a UICollectionViewDelegateFlowLayout , because this only supports scrolling in either horizontally or vertically direction. But I need scrolling in both directions. Therefore I have to use a

Change Background of UICollectionView Cell on Tap

青春壹個敷衍的年華 提交于 2019-11-27 00:53:20
问题 I have a UICollectionView that I have created programmatically. I would like for the collection view to behave in the following way: 1. User touches cell 2. Cell background color changes 3. User releases touch 4. Cell background color changes This should be a quick color change that happens just before the selector related to the tap action is executed in which the viewcontroller containing the collection view is popped off the stack. I have been looking at this question: UICollectionView