Giter Site home page Giter Site logo

ios8selfsizingcells's Introduction

iOS8SelfSizingCells

This is instagram app feed tableView demo use iOS8 Self Sizing Cells.

在iOS8以下,如果需要实现一个不同高度的Cell,那需要你手动动态计算高度,这便是一个繁琐的事情,而且富有挑战性,需要把空间复杂度转换为时间复杂度之类的优化。而在iOS8新的SDK里面提供了self sizing cells新功能,已经不再需要手动计算高度啦!不过还需要满足以下三个条件:

1、使用Autolayout进行UI布局约束。 2、指定你的TableView的estimatedRowHeight属性的默认值。 3、指定你的TableView的rowHeight属性为UITableViewAutomaticDimension。

总体而言,伪代码如下:

- (void)viewDidload {
    self.yourTableView.estimatedRowHeight = 44.0;
    self.yourTableView.rowHeight = UITableViewAutomaticDimension;
}

详细的做法可以参考一下Demo。

去掉计算高度的TableViewDelegate方法。

永远不用实现- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath方法和- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath方法。

#底层的流程讲解: 后续完善到wiki

#使用心得:
只要克服自己的不喜欢,爱上AutoLayout,加上size class。你会发现世界不一样了,但是autolayout很需要空间想象力,千万不要约束错了哦!不然self sizing cells不起作用的。

#感谢 使用的富文本Label来自Nigel GrangeWPAttributedMarkup开源库,很感谢他的帮助。

#预览图 image image

ios8selfsizingcells's People

Contributors

xhzengaib avatar

Watchers

BCODE avatar James Cloos 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.