zoukankan      html  css  js  c++  java
  • [翻译] HTKDynamicResizingCell

    HTKDynamicResizingCell

    https://github.com/henrytkirk/HTKDynamicResizingCell

    Subclassed UITableView/UICollectionView cells that will auto calculate their size so long as AutoLayout constraints are applied correctly. For iOS 7+. Works similar to how iOS 8's auto sizing of cells work.

    继承自UITableView/UICollectionView的cell,支持自动布局,iOS7.0以上,就像iOS8的自动布局那样子。

    Adding to your project:

    添加到项目当中:

    Cocoapods

    CocoaPods is the recommended way to add HTKScrollingNavigationController to your project.

    1. Add a pod entry for HTKScrollingNavigationController to your Podfile pod 'HTKDynamicResizingCell', '~> 0.0.1'
    2. Install the pod(s) by running pod install.
    3. Subclass HTKDynamicResizingTableViewCell or HTKDynamicResizingCollectionViewCell where you wish to use it.
    4. Make sure Auto-layout is setup correctly. See comments in classes for help.

    Autolayout Tips:

    自动布局需要注意的地方:

    For AutoLayout to be correct, make sure you complete the following:

    为了能够正确的自动布局,你需要确定以下几点:

    1. For height to calculate correctly, set hugging/compression priorites for all labels. This is one of the most important aspects of having the cell size itself. setContentCompressionResistancePriority needs to be set for all labels to UILayoutPriorityRequired on the Vertical axis. This prevents the label from shrinking to satisfy constraints and will not cut off any text. i.e. [self.label setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];

    2. Set PreferredMaxLayoutWidth for all labels that will have a auto height. This should equal width of cell minus any buffers on sides. i.e self.label.preferredMaxLayoutWidth = defaultSize - buffers;

    3. Set any imageView's images correctly so they have proper size. Remember if you don't set a fixed width/height on a UIImageView it will use the 1x intrinsic size of the image to calculate a constraint. So if your image isn't sized correctly it will produce an incorrect value.

    Screen shot:

    截图:

  • 相关阅读:
    杭电ACM 1297 Children’s Queue
    杭电ACM 1297 Children’s Queue
    Delta-wave
    
    <MySQL>MySQL创建表及相关约束
    <MySQL>MySQL的基本操作(增,删,改)
    <MySQL>MySQL的安装及安装中存在的问题
    <python>python中拷贝的问题
    <python>简单的学生管理系统V1.0
    <python>编写装饰器,为多个函数加上记录调用功能,要求每次调用函数都将被调用的函数名称写入文件
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/4217223.html
Copyright © 2011-2022 走看看