uicollectionviewlayout

How to add an UICollectionViewLayout programmatically?

余生颓废 提交于 2020-01-02 12:17:12
问题 I'm trying to setup a UICollectionViewLayout programmatically. I'm using a UICollectionView also without using storyboards, as well as settings its constraints. I've followed Ray Wenderlich tutorial on the subject with some changes to adapt the code to Swift 3 (as AZCoder2 did https://github.com/AZCoder2/Pinterest). Since all these examples uses storyboards, I've also introduced some changes to create the UICollectionView and its UICollectionViewLayout : collectionViewLayout = PinterestLayout

nil label for custom UICollectionCell

不羁的心 提交于 2020-01-02 08:57:28
问题 EDIT : seems like same question as this I made collection view with custom layout and cell but my cell's positions were a little off so I decided to number them so that I could debug it easier. I followed this guy's answer to number my cell using labels. Somehow myLabel was nil and caused my app to crash. I believe I have connected the outlets correctly but maybe someone could provide a list for me to check if I am doing anything wrong. ViewController import UIKit class ViewController:

Is it possible to zoom UICollectionView as a unit?

别说谁变了你拦得住时间么 提交于 2020-01-02 06:20:45
问题 We have a level map view in our latest project. It includes the level markers as UICollectionViewCells and various UICollectionReusableViews for fun decoration. We would like to be able to zoom in / out (it is a big map). I had hoped I could make use of the internal UIScrollView to do so, however, you can't zoom yourself... only a subview. Is there anyway to do this outside of individually scaling and relocating each element as I zoom? Feels like it should be a common thing and thus a more

Is it possible to zoom UICollectionView as a unit?

最后都变了- 提交于 2020-01-02 06:20:13
问题 We have a level map view in our latest project. It includes the level markers as UICollectionViewCells and various UICollectionReusableViews for fun decoration. We would like to be able to zoom in / out (it is a big map). I had hoped I could make use of the internal UIScrollView to do so, however, you can't zoom yourself... only a subview. Is there anyway to do this outside of individually scaling and relocating each element as I zoom? Feels like it should be a common thing and thus a more

collectionViewContentSize() vs contentSize

折月煮酒 提交于 2020-01-01 06:26:14
问题 What is the difference between collectionViewController.collectionViewLayout.collectionViewContentSize() and collectionViewController.collectionView.contentSize ? What do you prefer to use? 回答1: collectionViewContentSize() is a method you can override (in the layout) to generate the size dynamically. contentSize is a property of collectionView that is going to be used if there is no such override. It is similar to a UITableView 's rowHeight vs. the UITableViewDelegate 's

How can I set the entire header view to UICollectionView?

女生的网名这么多〃 提交于 2020-01-01 03:02:27
问题 I want to set the header to collection view, just like UITableViewController's setTableHeader does. I found the way to set the each section's header on collection view, but I couldn't find how to set the header view of the entire header. Apple's reference of UICollectionViewLayout says "Supplementary views present data but are different than cells. Unlike cells, supplementary views cannot be selected by the user. Instead, you use supplementary views to implement things like header and footer

UICollectionViewFlowLayout subclass crashes accessing array beyond bounds while scrolling and reloading

☆樱花仙子☆ 提交于 2019-12-31 12:08:53
问题 I have a UICollectionView that uses a custom subclass of UICollectionViewFlowLayout to make the section headers stick to the top of the screen while scrolling just like UITableView's plain style. My code is based on this approach: http://blog.radi.ws/post/32905838158/sticky-headers-for-uicollectionview-using In addition, the collection view is set up to load more results when the user scrolls to the bottom. That is, when the user gets to the bottom of the collection view, a web request loads

Setting size of UICollectionViewCell in a way that there is no interim spacing in between

空扰寡人 提交于 2019-12-31 07:09:08
问题 I'm using an UICollectionView on which I want to place seven cells side by side. The whole screen should be used for this. Currently, I'm using the width of the collection view and divide it by seven. Now I get an item width of 45.71429 on an iPhone 4. Between some cells there is an interim spacing. How can I handle this? I want to fill out the whole screen and all items should have the same size. One option which comes to my mind is to round the value and use the remaining value as inset.

UICollectionViewFlowLayout minimumInteritemSpacing doesn't work

删除回忆录丶 提交于 2019-12-30 08:38:30
问题 I've got two problems with my UICollectionView: minimumInteritemSpacing doesn't work it overflows horizontally on iOS 6 I set up the layout like this: UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; layout.itemSize = CGSizeMake(70.0f, 70.0f); layout.scrollDirection = UICollectionViewScrollDirectionVertical; layout.minimumLineSpacing = 0.0f; layout.minimumInteritemSpacing = 0.0f; _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero

UICollectionView remove section breaks with UICollectionViewFlowLayout

我只是一个虾纸丫 提交于 2019-12-29 06:22:14
问题 I have a dataset that is divided into multiple sections, however, I'd like to display this in a collectionView without breaks between sections. Here's an illustration of what I want to achieve: Instead of: 0-0 0-1 0-2 0-3 1-0 1-1 2-0 3-0 I want: 0-0 0-1 0-2 0-3 1-0 1-1 2-0 3-0 I realize the solution likely lies with a custom UICollectionViewLayout subclass, but I'm not sure how to achieve something like this. Thanks 回答1: You are correct that you need to subclass UICollectionViewLayout. The