Swift - 实现点击cell动态修改高度
Swift - 实现点击cell动态修改高度

效果

源码
https://github.com/YouXianMing/Swift-Animations
//
// TapCellAnimationController.swift
// Swift-Animations
//
// Created by YouXianMing on 16/8/30.
// Copyright © 2016年 YouXianMing. All rights reserved.
// import UIKit class 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.executeInMainQueue({ addText("AFNetworking is a delightful networking library for iOS and Mac OS X. It's built on top of the Foundation URL Loading System, extending the powerful high-level networking abstractions 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, iPad, and Mac. Choose AFNetworking for your next project, or migrate over your existing projects—you'll be happy you did!") addText("黄色的树林里分出两条路,可惜我不能同时去涉足,我在那路口久久伫立,我向着一条路极目望去,直到它消失在丛林深处。但我却选了另外一条路,它荒草萋萋,十分幽寂,显得更诱人、更美丽,虽然在这两条小路上,都很少留下旅人的足迹,虽然那天清晨落叶满地,两条路都未经脚印污染。呵,留下一条路等改日再见!但我知道路径延绵无尽头,恐怕我难以再回返。也许多少年后在某个地方,我将轻声叹息把往事回顾,一片树林里分出两条路,而我选了人迹更少的一条,从此决定了我一生的道路。") addText("★タクシー代がなかったので、家まで歩いて帰った。★もし事故が発生した场所、このレバーを引いて列车を止めてください。(丁)为了清楚地表示出一个短语或句节,其后须标逗号。如:★この薬を、夜寝る前に一度、朝起きてからもう一度、饮んでください。★私は、空を飞ぶ鸟のように、自由に生きて行きたいと思った。*****为了清楚地表示词语与词语间的关系,须标逗号。标注位置不同,有时会使句子的意思发生变化。如:★その人は大きな音にびっくりして、横から飞び出した子供にぶつかった。★その人は、大きな音にびっくりして横から飞び出した子供に、ぶつかった。") addText("Two roads diverged in a yellow wood, And sorry I could not travel both And be one traveler, long I stood And looked down one as far as I could 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 the 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 should 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 ..< self.datas.count { indexPaths.append(NSIndexPath(forItem: i, inSection: ))
}
self.tableView.insertRowsAtIndexPaths(indexPaths, withRowAnimation: .Fade) GCDQueue.executeInMainQueue({ let cell = self.tableView.cellForRowAtIndexPath(NSIndexPath(forItem: , inSection: )) as! 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)
}
}
Swift - 实现点击cell动态修改高度的更多相关文章
- 点击cell动态修改高度动画
点击cell动态修改高度动画 效果 源码 https://github.com/YouXianMing/Animations // // TapCellAnimationController.m // ...
- Swift iOS tableView static cell动态计算高度
TableView是iOS开发中经常使用的组件.有些表格由于UILabel包括的文本字数不一样,须要显示的高度也会不同,因此须要动态计算static cell的高度.我用的是static cell,注 ...
- JQuery中点击超链接动态修改url连接地址无效
这篇随笔的标题真是好拗口,想表达的意思是,当点击超链接后,才去修改超链接的地址,此时超链接仍然链接的是是修改之前的页面,而不是修改之后的页面. 超链接代码如下: <a id="chao ...
- html中iframe根据子页面内容动态修改高度
JavaScript var browserVersion = window.navigator.userAgent.toUpperCase(); var isOpera = browserVersi ...
- 使用Autolayout实现UITableView的Cell动态布局和高度动态改变
本文翻译自:stackoverflow 有人在stackoverflow上问了一个问题: 1 如何在UITableViewCell中使用Autolayout来实现Cell的内容和子视图自动计算行高,并 ...
- UITableView自定义Cell中,纯代码编程动态获取高度
在UITableView获取高度的代理方法中,经常需要根据实际的模型重新计算每个Cell的高度.直接的做法是在该代理方法中,直接根据模型来返回行高:另 [1]-(CGFloat)tableView:( ...
- android中动态修改ImageView控件的宽高度
本例实现了动态修改ImageView控件的宽高度,有两个按钮,一个按钮实现放大image,一个按钮实现缩小image activity_main.xml <?xml version=" ...
- iOS 动态修改导航栏颜色 UINavigationBar
示例 所谓动态修改 意思是 在当前页面滚动的过程中 亦或 是在 触发返回事件\进入一个新的页面 导航栏的动态变化 由于系统级别的navBar 高度集成 很多自己想实现的功能 很不好弄 如果是通过 ...
- Ida动态修改android程序的内存数据和寄存器数值,绕过so文件的判断语句
我们继续分析自毁程序密码这个app,我们发现该程序会用fopen ()打开/proc/[pid]/status这个文件,随后会用fgets()和strstr()来获取,于是我们在strstr()处下个 ...
随机推荐
- 第二章 第二个spring-boot程序(转载)
本编博客转发自:http://www.cnblogs.com/java-zhao/p/5336369.html 上一节的代码是spring-boot的入门程序,也是官方文档上的一个程序.这一节会引入s ...
- python学习之路-day2-pyth基础2
一. 模块初识 Python的强大之处在于他有非常丰富和强大的标准库和第三方库,第三方库存放位置:site-packages sys模块简介 导入模块 import sys 3 sys模 ...
- win10下vs2015配置Opencv3.1.0过程详解
下载安装Opencv3.1.0 下载Opencv3.1.0,进入官网,点击opencv for windows即可下载. 点击运行下载好的文件.实际上,opencv的安装程序就是解压缩文件,个人因为 ...
- Linux内核实现中断和中断处理(二)
第一部分移步传送门召唤!!:http://www.cnblogs.com/lenomirei/p/5562086.html 上回说了Linux内核实现中断会把中断分为两部分进行处理,上回讲了上部分,这 ...
- 数据库 sql
近期项目中会用到oracle,mysql,两者的建表sql 类型,函数都会混淆.现在特意整理一下: mysql :now(), CONCAT("","",& ...
- BZOJ 4247: 挂饰 题解
Description JOI君有N个装在手机上的挂饰,编号为1...N. JOI君可以将其中的一些装在手机上. JOI君的挂饰有一些与众不同--其中的一些挂饰附有可以挂其他挂件的挂钩.每个挂件要么直 ...
- js学习---常用的内置对象(API)小结 :
内置对象(API): 日期 Date: getFullYear() 返回完整的4位的年份 如:2016 getMonth() 返回月份,从0开始 getDate() 返回当前月的第几天,当 ...
- Microsoft Visual Studio 2010 VSTS单元测试指南
本来以为很简单的一个问题,今天预计10分钟搞定,结果到下班还没弄出结果,单元测试运行的时候一直处于无反应状态,最后估计可能是我装的2010有问题,结果到家一试果然是有问题,有时软件就是这么神奇. 言归 ...
- NY 269 VF
题目 求1—1000000000之间的数,它的各位数字之和为 s. dp[i][j]表示 i 位数,它的各位数之和为 j 的总个数. 这里假设第 i 位为 k,则前 i - 1 位的和应为 j - k ...
- as的一些常见问题
assets文件的存放目录在”src/main/”目录下,和java.res文件夹平级: aidl文件需要单独在”src/main/”目录下新建一个文件夹,然后创建对应的包名,将aidl文件放在包名对 ...