Code Monkey home page Code Monkey logo

czl0325 / zlcollectionview Goto Github PK

View Code? Open in Web Editor NEW
1.1K 14.0 164.0 15.49 MB

为应对类似淘宝首页,京东首页,国美首页等复杂布局而写的Collectionview。基于UICollectionView实现,目前支持标签布局,列布局,百分比布局,定位布局,填充式布局,瀑布流布局等。支持纵向布局和横向布局,可以根据不同的section设置不同的布局,支持拖动cell,头部悬浮,设置section背景色和自定义section背景view,向自定义背景view传递自定义方法。功能强大,超过Android的recyclerview,实现了电影选座等高难度的布局。

License: MIT License

Objective-C 99.31% Ruby 0.69%
collectionview collectionviewcell collectionviewflowlayout layout

zlcollectionview's Introduction

ZLCollectionView

为应对类似淘宝首页,京东首页,国美首页等复杂布局而写的ZLCollectionview。基于UICollectionView实现,目前支持标签布局,列布局,百分比布局,定位布局,填充式布局,瀑布流布局等。支持纵向布局和横向布局,可以根据不同的section设置不同的布局,支持拖动cell,头部悬浮,设置section背景色和自定义section背景view,向自定义背景view传递自定义方法。实现了电影选座等高难度的布局。
特别感谢donggelaile贡献了降低cpu占用率的代码

gif效果图

导入

支持cocoapod导入,最新版本 1.4.9

pod 'ZLCollectionViewFlowLayout' 

推荐项目

使用uitableview或者uicollectionview的朋友可以使用我的另外一个库 ZLCellDataSource
至少可以少写1/3的代码量,在开发界面可以快速帮你构建uitableview和uicollectionview
觉得好用的朋友可以去点个star

注意事项:

版本1.0开始加入了横向布局,有升级到1.0的,原来的类ZLCollectionViewFlowLayout提示找不到,请更换成ZLCollectionViewVerticalLayout即可,其余不变。如果不想升级可用 pod 'ZLCollectionViewFlowLayout','0.8.7.1'


  • ZLCollectionViewVerticalLayout ==== 纵向布局
  • ZLCollectionViewHorzontalLayout ==== 横向布局(暂时先做了标签页布局和瀑布流,其余的后续增加)

如果遇到以下错误, Unable to find a specification for ZLCollectionViewFlowLayout 请使用pod update命令来安装。

参数列表

可配置参数 类型 作用
isFloor BOOL 宽度是否向下取整,默认为YES,该参数一般不用改
canDrag BOOL 是否允许拖动cell,默认为NO
header_suspension BOOL 头部是否悬浮,默认为NO
layoutType ZLLayoutType 设置布局类型,适用于只有单一布局可省去写代理的代码
columnCount columnCount 在列布局中设置列数,适用于单一布局可省去写代理的代码
fixTop CGFloat header距离顶部的距离
columnSortType ZLColumnSortType 瀑布流列排序方式,按最小高度或者按顺序

布局名称 布局类型 作用
LabelLayout 标签页布局
ColumnLayout 列布局 瀑布流,单行布局,等分布局
PercentLayout 百分比布局
FillLayout 填充式布局
AbsoluteLayout 绝对定位布局

代理方法 作用 备注
- (ZLLayoutType)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewFlowLayout *)collectionViewLayout typeOfLayout:(NSInteger)section; 指定是什么布局 如没有指定则为FillLayout(填充式布局)
- (UIColor*)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewFlowLayout *)collectionViewLayout backColorForSection:(NSInteger)section; 设置每个section的背景色
- (UIImage*)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewFlowLayout *)collectionViewLayout backImageForSection:(NSInteger)section; 设置每个section的背景图
- (NSString*)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewFlowLayout *)collectionViewLayout registerBackView:(NSInteger)section; 自定义每个section的背景view,
- (ZLBaseEventModel*)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewFlowLayout *)collectionViewLayout backgroundViewMethodForSection:(NSInteger)section; 向每个section自定义背景view传递自定义方法 需要传递的自定义view必须继承ZLCollectionBaseDecorationView类,传递的ZLBaseEventModel对象,eventName:方法名(注意带参数的方法名必须末尾加:),parameter:参数
- (BOOL)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewFlowLayout *)collectionViewLayout attachToBottom:(NSInteger)section; 背景是否延伸覆盖到footerView 默认为NO
- (BOOL)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewFlowLayout *)collectionViewLayout attachToTop:(NSInteger)section; 背景是否延伸覆盖到headerView 默认为NO
- (NSInteger)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewFlowLayout )collectionViewLayout zIndexOfItem:(NSIndexPath)indexPath; 设置每个item的zIndex 默认为0
- (CATransform3D)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewFlowLayout )collectionViewLayout transformOfItem:(NSIndexPath)indexPath; 设置每个item的CATransform3D 默认为CATransform3DIdentity
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewFlowLayout )collectionViewLayout alphaOfItem:(NSIndexPath)indexPath; 设置每个item的alpha 默认为1
- (NSInteger)collectionView:(UICollectionView )collectionView layout:(UICollectionViewFlowLayout)collectionViewLayout columnCountOfSection:(NSInteger)section; 列布局中指定一行有几列 列布局需要的代理,默认为1
- (CGFloat)collectionView:(UICollectionView )collectionView layout:(UICollectionViewFlowLayout)collectionViewLayout percentOfRow:(NSIndexPath*)indexPath; 百分比布局中指定每个item占该行的几分之几 PercentLayout百分比布局需要的代理,如3.0/4,注意为大于0小于等于1的数字。不指定默认为1
- (CGRect)collectionView:(UICollectionView )collectionView layout:(UICollectionViewFlowLayout)collectionViewLayout rectOfItem:(NSIndexPath*)indexPath; 绝对定位布局中指定每个item的frame 绝对定位布局必须实现的代理。不指定默认为CGRectZero
- (void)collectionView:(UICollectionView )collectionView layout:(UICollectionViewFlowLayout)collectionViewLayout didMoveCell:(NSIndexPath*)atIndexPath toIndexPath:(NSIndexPath*)toIndexPath; 拖动cell的相关代理

用法

//在UICollectionView创建之前加入ZLCollectionViewFlowLayout

- (UICollectionView*)collectionViewLabel {
    if (!_collectionViewLabel) {
        ZLCollectionViewFlowLayout *flowLayout = [[ZLCollectionViewFlowLayout alloc] init];
        flowLayout.delegate = self;
        
        _collectionViewLabel = [[UICollectionView alloc]initWithFrame:self.view.bounds collectionViewLayout:flowLayout];
        _collectionViewLabel.dataSource = self;
        _collectionViewLabel.delegate = self;
        _collectionViewLabel.backgroundColor = [UIColor whiteColor];
        [_collectionViewLabel registerClass:[SEMyRecordLabelCell class] forCellWithReuseIdentifier:[SEMyRecordLabelCell cellIdentifier]];
        [_collectionViewLabel registerClass:[SEMyRecordHeaderView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:[SEMyRecordHeaderView headerViewIdentifier]];
    }
    return _collectionViewLabel;
}

//实现代理,如果不实现也可以自己直接设置self.sectionInset,self.minimumLineSpacing,self.minimumInteritemSpacing。但是这种设置不支持不同section不同数值

//指定section用的样式。LabelLayout是标签样式,ClosedLayout用于tableviewcell或者瀑布流,九宫格之类的。
- (ZLLayoutType)collectionView:(UICollectionView *)collectionView layout:(ZLCollectionViewFlowLayout *)collectionViewLayout typeOfLayout:(NSInteger)section {
    switch (section) {
        case 0:
            return LabelLayout;
        case 1:
        case 2:
            return FillLayout;
        case 3:
        case 4:
            return AbsoluteLayout;
        case 5:
        case 6:
            return PercentLayout;
        default:
            return ClosedLayout;
    }
}

//如果是ClosedLayout样式的section,必须实现该代理,指定列数
- (NSInteger)collectionView:(UICollectionView *)collectionView layout:(ZLCollectionViewFlowLayout*)collectionViewLayout columnCountOfSection:(NSInteger)section {
    switch (section) {
        case 7:
            return 4;
        case 8:
            return 2;
        case 9:
            return 1;
        default:
            return 0;
    }
}
//如果是百分比布局必须实现该代理,设置每个item的百分比,如果没实现默认比例为1
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(ZLCollectionViewFlowLayout*)collectionViewLayout percentOfRow:(NSIndexPath*)indexPath; {
    switch (indexPath.section) {
        case 5: {
            switch (indexPath.item) {
                case 0:
                    return 1.0/3;
                case 1:
                    return 2.0/3;
                case 2:
                    return 1.0/3;
                case 3:
                    return 1.0/3;
                case 4:
                    return 1.0/3;
                case 5:
                    return 1.0/4;
                case 6:
                    return 1.0/4;
                case 7:
                    return 1.0/2;
                case 8:
                    return 3.0/5;
                case 9:
                    return 2.0/5;
                default:
                    break;
            }
        }
        case 6: {
            if (indexPath.item % 2==0) {
                return 3.0/4;
            } else {
                return 1.0/4;
            }
        }
        default:
            return 1;
    }
}
//如果是绝对定位布局必须是否该代理,设置每个item的frame
- (CGRect)collectionView:(UICollectionView *)collectionView layout:(ZLCollectionViewFlowLayout*)collectionViewLayout rectOfItem:(NSIndexPath*)indexPath {
    switch (indexPath.section) {
        case 3: {
            CGFloat width = (collectionView.frame.size.width-200)/2;
            CGFloat height = width;
            switch (indexPath.item) {
                case 0:
                    return CGRectMake(0, 0, width, height);
                case 1:
                    return CGRectMake(width, 0, width, height);
                case 2:
                    return CGRectMake(0, height, width, height);
                case 3:
                    return CGRectMake(width, height, width, height);
                case 4:
                    return CGRectMake(width/2, height/2, width, height);
                default:
                    return CGRectZero;
            }
        }
            break;
        case 4: {
            switch (indexPath.item) {
                case 0:
                    return CGRectMake((collectionView.frame.size.width-20)/2-100, 0, 200, 30);
                default: {
                    NSInteger column = (collectionView.frame.size.width-20)/30;
                    return CGRectMake(((indexPath.item-1)%column)*30, 100+((indexPath.item-1)/column)*30, 20, 20);
                }
                    
            }
        }
            break;
        default:
            return CGRectZero;
    }
    return CGRectZero;
}

更新

v1.4.9 (2022.03.29)
  • 增加瀑布流排列方式的字段
v1.4.0 (2020.04.18)
  • 自定义背景view的代理方法增加
v1.3.1 (2020.04.14)
  • 修改填充式布局的bug
v1.3.0 (2020.03.25)
  • 增加头部偏移量设置
v1.2.0 (2019.12.25)
  • 降低cpu的占用率
v1.1.6 (2019.10.1)
  • 修复bug
v1.1.0 (2019.5.13)
  • 横向布局增加绝对定位布局
v1.0.3 (2019.5.7)
  • 修改适配swift
v1.0.2 (2019.2.20)
  • 拆分成横向布局和纵向布局两个类,使用方法和类名有所改变
v0.8.6 (2019.1.11)
  • 降低了头部不悬浮情况下的cpu占用率
v0.8.2 (2018.9.26)
  • 去掉基础布局
  • 提取代理出来
  • 增加高度向下取整
v0.7.0 (2018.8.6)
  • 增加头部可以悬浮的设置
v0.6.2 (2018.7.26)
  • 增加拖动cell和高度自适应的测试。高度自适应需要用到第三方库
v0.5.3 (2018.7.12)
  • 增加自定义section背景图
v0.5 (2018.7.10)
  • 增加了可以设置每个section的背景色
v0.4.1 (2018.7.8)
  • 修改了一些bug
v0.3.0 (2018.3.1)
  • 新增加了绝对定位布局,自己定义每个item的位置,可以做层叠布局,电影选座布局等等,详细操作请见demo
v0.2.0 (2018.2.27)
  • 新增加了填充式布局,详细操作请见demo
v0.1.1 (2018.2.26)
  • 修复百分比布局的若干bug
v0.1.0 (2018.1.29)
  • 新增加了百分比布局,详细操作请见demo

zlcollectionview's People

Contributors

czl0325 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zlcollectionview's Issues

对section背景进行一些操作的代理方法.... loadView,怎么用?

这个库用起来很好,有个小疑问,

//对section背景进行一些操作

  • (void)collectionView:(UICollectionView *)collectionView layout:(ZLCollectionViewFlowLayout *)collectionViewLayout loadView:(NSInteger)section {
    //NSLog(@"当前section=%zd,需要处理什么操作?",section);
    }

这个代理方法究竟有何用处?

在这个方法里没法获取到背景视图?

没找到相关的获取背景视图接口。

还请指教,谢谢~

拖拽移动问题

将canDrag设置为YES的时候可以指定某个Item不可以拖动么

无法监听到滚动到第几 section 值

业务中需要监听滚动时候的section 从而设置头部导航栏 title 需求, 使用ZL 不行,但使用系统的layout可以监听到

参考 https://www.cnblogs.com/qqcc1388/p/5891665.html 方法 ~

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    NSInteger currentIndex = 0;
    CGRect visibleRect = (CGRect){.origin = self.collectionViewLabel.contentOffset, .size = self.collectionViewLabel.bounds.size};
    CGPoint visiblePoint = CGPointMake(CGRectGetMidX(visibleRect), CGRectGetMidY(visibleRect));
    NSIndexPath *visibleIndexPath = [self.collectionViewLabel indexPathForItemAtPoint:visiblePoint];

    if (currentIndex == visibleIndexPath.section || visibleIndexPath == nil) {
        return;
    }
    currentIndex = visibleIndexPath.section;
    NSLog(@"currentIndex: %ld",currentIndex);
}

这样的方式也不行

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    NSInteger currentIndex = 0;
    CGRect visibleRect = (CGRect){.origin = self.collectionViewLabel.contentOffset, .size = self.collectionViewLabel.bounds.size};
    CGPoint visiblePoint = CGPointMake(CGRectGetMinX(visibleRect), CGRectGetMinY(visibleRect));
    UICollectionViewLayoutAttributes *attribute = [[self.collectionViewLabel.collectionViewLayout layoutAttributesForElementsInRect:visibleRect] firstObject];
    if (attribute == nil) {
        return;
    }
    currentIndex = attribute.indexPath.section;
    NSLog(@"currentIndex: %ld",currentIndex);
}

针对瀑布流的疑问

如果要用瀑布流 ,UICollectionView+ARDynamicHeightLayoutCell 是必须要用的吗 请问,那为什么不把这个文件 也放到pod的库里?

minimumLineSpacingForSectionAtIndex 在不同布局下规则不一致

minimumLineSpacingForSectionAtIndex 设置为10
目前一个页面不同section 采用的是PercentLayout 与ClosedLayout两种方式混合排序。当设置了行间距的时候发现 在PercentLayout的样式下 系统默认在第一行上方加入一个 行间距。 但是在ClosedLayout 样式下是在最后一行下方加入一个行间距。 这导致了 当这两个样式交界处的时候 间隙无法去调整的问题。不知道能否改成minimumLineSpacingForSectionAtIndex 既不在最上面也不在最下面添加间距 只设置行与行之间的间距 最上面下面的间距统一交给insetForSectionAtIndex来处理

您好

遇到过cell无法显示,但是上的子视图显示出来了嘛

悬浮头部布局错乱问题

就是我有个页面是问卷考察的页面,是纵向布局的,两列的,设置了ClosedLayout类型,选项可以展开和收起,我头部设置了悬浮。滚动一定位置后,点击头部的收起,然后头部布局会错乱,item都是好的,头部会显示在最底部,滚动又变好了,现在为了实现需求头部设置了固定。

使用 NSLayoutConstraint 进行header拉伸的时候会崩溃

将header 中的 imageview 跟viewcontroller 中的view 进行绑定会崩溃

NSLayoutConstraint *layout = [self.backImage.topAnchor constraintEqualToAnchor:collectionView.topAnchor];
[NSLayoutConstraint activateConstraints:@[layout]];

但是使用普通的UICollectionViewFlowLayout 却没有问题

错误信息:

Terminating app due to uncaught exception 'NSGenericException', reason: 'Unable to activate constraint with anchors <NSLayoutYAxisAnchor:0x2814699c0 "UIImageView:0x10ac6f2a0.top"> and <NSLayoutYAxisAnchor:0x28144ad00 "UICollectionView:0x10c176c00.top"> because they have no common ancestor. Does the constraint or its anchors reference items in different view hierarchies? That's illegal.'

有关float的相等判断

有关float的相等判断,建议改用 exp (A - B) < 0.01或其它更准确的判断方式。因为精度问题,在判断上时常会导致布局错乱。

越界问题

在prepareLayout方法中应该加上
[self.headerAttributesArray removeAllObjects];
不然在悬浮的时候遍历self.headerAttributesArray 会造成self.collectionHeightsArray越界

cell高度差比较小的时候 minimumLineSpacing 出现异常

新建一个项目,把我提供的代码复制进去运行,就会出现如图这种情况
E43DAEC65AB6C71D58D2349EE925DFA3

//
// ViewController.m
// ZLCollectionTest
//
// Created by cxz31415 on 2020/8/17.
// Copyright © 2020 cxz31415. All rights reserved.
//

#import "ViewController.h"
#import "ZLCollectionViewVerticalLayout.h"
@interface ViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,ZLCollectionViewBaseFlowLayoutDelegate>
@Property (copy, nonatomic) NSString *collectionViewCellName;
@Property (strong, nonatomic) UICollectionView *collectionView;
@Property (strong, nonatomic) NSMutableArray *dataArrM;
@EnD

@implementation ViewController

#define MainScreen [UIScreen mainScreen]
#define MainScreenScale MainScreen.scale
#define ScreenF [MainScreen bounds]
#define ScreenS ScreenF.size
#define ScreenW ScreenS.width

  • (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    self.view.backgroundColor = [UIColor grayColor];

    _dataArrM = [NSMutableArray array];
    for (int i = 0; i < 100; i++) {
    [_dataArrM addObject:@(arc4random_uniform(4) * 20 + 10)];
    }
    [self initCollectionView];
    }

-(void)initCollectionView{
_collectionViewCellName = @"UICollectionViewCell";

ZLCollectionViewVerticalLayout *layout = [[ZLCollectionViewVerticalLayout alloc] init];
//水平方向滚动
//layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
layout.delegate = self;
layout.minimumLineSpacing = 20;
layout.minimumInteritemSpacing = 10;

_collectionView = [[UICollectionView alloc]initWithFrame:ScreenF collectionViewLayout:layout];
[_collectionView registerClass:[UICollectionViewCell class]forCellWithReuseIdentifier:_collectionViewCellName];

_collectionView.delegate = self;
_collectionView.dataSource = self;
//内容较少时也有垂直方向反弹效果(用于上下拉加载数据)
_collectionView.alwaysBounceVertical = YES;
_collectionView.backgroundColor = UIColor.clearColor;

// _collectionView.scrollEnabled = NO;
[self.view addSubview:_collectionView];
}

#pragma - mark - collection view datasoure

  • (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.dataArrM.count;
    }

  • (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 1;
    }

  • (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:_collectionViewCellName forIndexPath:indexPath];
    cell.clipsToBounds = YES;
    cell.layer.cornerRadius = 20;
    cell.backgroundColor = UIColor.whiteColor;
    return cell;
    }

-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
NSNumber *number = _dataArrM[indexPath.item];
return CGSizeMake((ScreenW - 30) * 0.5, number.floatValue);
}

-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
return UIEdgeInsetsMake(0, 10, 0, 10);
}

@EnD

控制台报错误,我搜了一下, 是设置translatesAutoresizingMaskIntoConstraints = false才会出现的

控制台报以下错误,我搜了一下, 是设置translatesAutoresizingMaskIntoConstraints = false才会出现的。

Changing the translatesAutoresizingMaskIntoConstraints property of a UICollectionReusableView that is managed by a UICollectionView is not supported, and will result in incorrect self-sizing. View: <ZLCollectionReusableView: 0x1077e9d40; baseClass = UICollectionReusableView; frame = (0 0; 557.143 121); layer = <CALayer: 0x282a6e680>>

性能问题

header_suspension 开启后会有 性能问题 里面的浮点数比较 对占用比较多的性能

有个小小的建议

首先对大哥贡献出这不错的项目表示感谢和赞赏!不过有个小小的建议能否提一下,不知道大哥平时写代码是这样子,还是因为这个是github项目这样子,就是我们都很希望你加入一点代码注释,最好是越详细越好!辛苦了

现在可以支持Swift了吗

在Swift项目中使用了下,发现不行,是我操作不对,还是此库本身不支持Swift?

ps:按理说,桥接一下,应该不会有问题的。

还请指教!

内存泄漏

检测到 内存泄漏 CGFloat *columnHeight = (CGFloat *) malloc(self.columnCount * sizeof(CGFloat));
malloc free 应该成对出现吧

SIGSEGV

0 libobjc.A.dylib objc_retain + 16
1 ZLCollectionViewFlowLayout -[ZLCollectionViewVerticalLayout collectionViewContentSize] + 60
2 UIKitCore -[UICollectionView _updateAnimationDidStop:finished:context:] + 1724
3 UIKitCore ___71-[UICollectionView _updateWithItems:tentativelyForReordering:animator:]_block_invoke.1926 + 88
4 Foundation __NSFireDelayedPerform + 412
5 CoreFoundation _CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 28
6 CoreFoundation ___CFRunLoopDoTimer + 880
7 CoreFoundation ___CFRunLoopDoTimers + 276
8 CoreFoundation ___CFRunLoopRun + 1640
9 CoreFoundation CFRunLoopRunSpecific + 424
10 GraphicsServices GSEventRunModal + 160
11 UIKitCore UIApplicationMain + 1932

miss-spelling of minimumLineSpacing?

Seems in line 360 -370:

CGPoint leftPt = CGPointMake(attributes.frame.origin.x - minimumLineSpacing, attributes.frame.origin.y);

I do not dive into logic.
It's not miss-spelling?

minimunItemSpacing?

How i can use insert/delete animation ?

As the title mentioned, I wonder how can i use animations such as fade, top, bottom, etc.. when insert/delete items.
If i perform batch with default animation when inserting items, it turned out weird animation glitch. .

在iPad上屏幕旋转后界面约束失效

用demo跑在ipad ios 15上,屏幕旋转后界面布局失效
临时解决办法

override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        collectionViewLabel?.reloadData()
    }

希望能解决

PercentLayout设置百分比布局 数据源不足时宽度不对

当我设置PercentLayout布局时候
在percentOfRow 中 我设置了section == 1 时候返回 1.0/5
section == 1 边距设置的方法 insetForSectionAtIndex 设置为 UIEdgeInsetsMake(0, 23, 0, 23);
列间距 minimumInteritemSpacingForSectionAtIndex section == 1时候 设置为24;
那么按照我的理解section == 1 时候 没个cell的宽度应该为
CGFloat w = (SCREENWIDTH - 244-232)/5;
但是我发现 当我的数据源为5时候 w确实没有问题 但是当数据源不够五个时 这个宽系统计算是错误。
求大神能帮忙解决一下。项目马上提交了 碰到这个问题 很急,在线等。谢谢了先

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.