Coder Social home page Coder Social logo

mitchellporter / htkdynamicresizingcell Goto Github PK

View Code? Open in Web Editor NEW

This project forked from henrytkirk/htkdynamicresizingcell

0.0 2.0 0.0 712 KB

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.

License: Apache License 2.0

Ruby 1.89% Objective-C 88.09% Swift 10.02%

htkdynamicresizingcell's Introduction

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.

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:

Sample Screenshot

Change log:

v0.0.1: Initial project commit

Questions? Email: [email protected] or Web: http://www.henrytkirk.info

htkdynamicresizingcell's People

Contributors

bcylin avatar henrytkirk avatar

Watchers

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