Swift and swiftcode
Swift-click cell to dynamically change the height
Effect
Source code
Https://github.com/YouXianMing/Swift-Animations
/// TapCellAnimationController. swift // Swift-Animations // Created by YouXianMing on 16/8/30. // Copyright©2016 YouXianMing. All rights reserved. // import UIKitclass TapCellAnimationController: NormalTitleViewController, UITableViewDelegate, UITableViewDataSource {private var tableView: UITableView! Private var datas: [CellDataAdapter]! Override func setup () {super. setup () datas = [CellDataAdapter] () tableView = UITableView (frame: (contentView ?. Bounds )!) TableView. delegate = self tableView. dataSource = self tableView. separatorStyle =. None ShowTextCell. RegisterTo (tableView) contentView ?. AddSubview (tableView) func addText (string: String) {let model = ShowTextModel (string) datas. append (ShowTextCell. adapter (data: model, cellHeight: ShowTextCell. heightWithData (model), type: EShowTextCellType. normalType. rawValue)} GCDQueue.exe cuteInMainQueue ({addText ("AFNetworking is a delightful networking library for iOS and Mac OS X. it's built on top of the Foundation URL Loading System, e Xtending the powerful high-level networking implements actions built into Cocoa. it has a modular architecture with well-designed, feature-rich APIs that are a joy to use. perhaps the most important feature of all, however, is the amazing community of developers who use and contribute to AFNetworking every day. AFNetworking powers some of the most popular and critically-acclaimed apps on the iPhone, iPa D, and Mac. Choose AFNetworking for your next project, or migrate over your existing projects-you'll be happy you did! ") AddText. However, I chose another path, which is deserted and silent, and more attractive and beautiful. Although there are few travel trails on these two roads, even though the fallen leaves were full in the early morning, the two roads were not polluted by footprints. Oh, leave a path and wait for another day to see you! But I know that the path is endless, and I am afraid it is difficult for me to return. Maybe some years later, I will sigh softly and review the past. There are two ways in the woods, and I chose one with fewer traces, which decides the path of my life. ") AddText ("★Zookeeper is the generation of zookeeper, Zookeeper, and zookeeper.★When an accident occurs in the upper-right corner, the dead-right corner of the train, the upper-right corner of the train, the upper-right corner of the train, and the upper-right corner of the train. (Ding) to clearly express a phrase or sentence, it must be followed by a comma. For example:★Before the sleep, the system was once busy. When the morning was full, the system was always busy.★In the private sector, the flying birds in the air, and the free school of life are all connected. * ***** To clearly express the relationship between words and words, a comma is required. Different positions may change the meaning of a sentence. For example:★The speaker is a great speaker, and the speaker is a senior speaker.★He was a senior speaker, and a senior speaker. ") AddText (" Two roads diverged in a yellow wood, And sorry I cocould not travel both And be one traveler, long I stood And looked down one as far as I cocould To where it bent in the undergrowth; Then took the other, as just as fair, And having perhaps the better claim, because it was grassy and wanted wear; Though as for that passing there Had worn them really about the same, And both that morning Equally lay In leaves no step had trodden black. Oh, I kept the first for another day! Yet knowing how way leads on to way, I doubted if I shocould ever come back. I shall be telling this with a sigh Somewhere ages and ages hence: Two roads diverged in a wood, and I-I took the one less traveled by, And that has made all the difference. ") var indexPaths = [NSIndexPath] () for I in 0 .. <self. datas. count {indexPaths. append (NSIndexPath (forItem: I, inSection: 0)} self. tableView. insertR OwsAtIndexPaths (indexPaths, withRowAnimation:. Fade) GCDQueue.exe cuteInMainQueue ({let cell = self. tableView. cellForRowAtIndexPath (NSIndexPath (forItem: 0, inSection: 0)! CustomCell cell. selectedEvent ()}, afterDelaySeconds: 0.5)}, afterDelaySeconds: 0.5)} func tableView (tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath)-> UITableViewCell {return tableView. dequeueAndLoadContentReusableCellFromAdapter (datas [indexPath. row], indexPath: indexPath, tableView: tableView)} func tableView (tableView: UITableView, numberOfRowsInSection section: Int )-> Int {return datas. count} func tableView (tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath)-> CGFloat {return datas [indexPath. row]. cellHeight!} Func tableView (tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {tableView. selectedEventWithIndexPath (indexPath )}}