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()处下个 ...
随机推荐
- 状态机学习(三)解析JSON
来自 从零开始的 JSON 库教程 从零开始教授如何写一个符合标准的 C 语言 JSON 库 作者 Milo Yip https://zhuanlan.zhihu.com/json-tutorial ...
- 如何在 IIS 中设置 HTTPS 服务
Windows Server2008.IIS7启用CA认证及证书制作完整过程 这篇文章介绍了如何安装证书申请工具: 如何在iis创建证书申请: 如何使用iis申请证书生成的txt文件,在工具中开始申请 ...
- [Linux]服务管理:rpm包, 源码包
--------------------------------------------------------------------------------------------------- ...
- 苹果会在明后年推出13寸屏iPad吗?
摘要:苹果推大屏iPad的传闻由来已久,近日有国外媒体再次撰文称,这种大屏iPad不仅是苹果Mac继任者,同时也是Surface的有利竞争者……这真的可能吗?这只是分析师的捕风捉影,还是真有这种可能? ...
- N皇后
#include <stdio.h> #include <math.h> ], a[]; /*int place(int k) { for(int i = 1; i < ...
- Windows 8.1 应用再出发 - 几种新增控件(1)
Windows 8.1 新增的一些控件,分别是:AppBar.CommandBar.DatePicker.TimePicker.Flyout.MenuFlyout.SettingsFlyout.Hub ...
- MyBatis学习之路之configuration配置
1.首先讲解的是MyBatis核心配置文件configuration.xml的配置 一个完整的configuration.xml配置顺序如下: properties,settings,typeAlia ...
- Swing Note
2. Swing容器: 内容窗格.分层窗格.玻璃窗格和一个可选的菜单条.(这四个同时包含在根窗格里)(请分别向其中添加组件) ...
- 【概念笔记】JavaEE - web part1
IT`huhui前言录 想对学习的内容进行下简易的总结方便自己回头复习. 但是还有很多地方是不完善的需要慢慢修改. 持续更新. Web 服务器 IIS 微软主推 Apache C写的 Tomcat j ...
- [Hyper-V]在Windows 8.1 操作系统中启用Hyper-V功能
描述: 如何在Windows 8.1 操作中启用Hyper-V功能 实现步骤: 1,安装Hyper-V 1 打开Control Panel,点击Progress 2 点击Turn Windows fe ...