Giter VIP home page Giter VIP logo

edison9888 / jhcellconfig Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jc-hu/jhcellconfig

0.0 2.0 0.0 832 KB

Flexible way to build a UITableView contains different kinds of cells, without switch...case, super easy to modify.- 一种十分灵活易变的适用于创建有多种cell的UITableView的方法,不需要使用switch...case,在调整不同种cell的顺序、及增删某种cell时极其方便

License: MIT License

Objective-C 99.35% C 0.65%

jhcellconfig's Introduction

JHCellConfig

  • Flexible way to build a UITableView contains different kinds of cells, without switch...case, super easy to modify.
  • 一种十分灵活易变的适用于创建有多种cell的UITableView的方法,不需要使用switch...case,在调整不同种cell的顺序、及增删某种cell时极其方便

本类相当于将tableView中cell所需的基本信息存储下来,以便放到数组中管理

关于如何使用请看demo,注释写了很多

优点:改变不同类型cell的顺序、增删时,极为方便,只需改变VC中数据源数组即可,无需在多个tableView代理方法中逐个修改

缺点:大家帮我找一找,什么样的需求会难以实现,感谢^_^

  • 加入了“高级评论”的示例代码,根据数据源数组来显示评论列表,个数不确定、评论内容长度不确定(即cell高度不确定),可在工程中搜索 高级评论 查看相关代码。

  • 加入了cell上按钮触发事件绑定的示例代码,手势等同理。

  • 对不同种cell进行不同设置时,通过 其对应的 cellConfig.title 进行判断。

    (这样,不论你将dataArray如何修改,插入、删除、改变顺序,都无须再次修改这里的判断)

此方法的核心**就是两个字 “化简”。

通常写多种cell时,不同cell有不同设置,需要在多个代理方法中进行判断,而且很多是用switch...case来写。这样一旦修改,就需要修改多处。

而通过JHCellConfig类提供的方法进行化简后,要改两种cell的顺序,就只需交换两行对应的代码;要删除或添加某种cell,就只需注释/删除或添加一行代码。

  y = x + 3x + 5x  化简-> y = 9x
  PM 提需求: 把x换成a!
  y = x + 3x + 5x 需修改3处,y = 9x只需修改1处

我会不定期更新此demo,加上一些“高级”用法,即应对不同需求时的用法,可以关注下面的微信公众号,更新时我会给你们发消息


Email:[email protected]

新浪微博:@胡竞尘_要做全面发展的好青年

QQ:601541744

微信公众号:hujingchen4096

jhcellconfig's People

Contributors

jc-hu avatar

Watchers

 avatar  avatar

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.