我们上一节主要讲了简单创建一个表格填充一些数据
上一节地址:http://www.jb51.cc/article/p-cuujvvgb-bbq.html
这节我们对tableView每一行的细节做一些修饰
var _dataSubtitleArray:[String]!
//准备数据 _dataArray=[String]() _dataSubtitleArray=[String]() for i in 1...10 { _dataArray.append("第\(i)行") _dataSubtitleArray.append("副标题\(i)") } _tableView.dataSource=self
//设置每一行的内容 func tableView(tableView: UITableView,cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { var cellid="cellid" var cell=tableView.dequeueReusableCellWithIdentifier(cellid) as? UITableViewCell if cell==nil { //此处参数style 需要设置为 Subtitle 才可以展示出来副标题 cell=UITableViewCell(style: UITableViewCellStyle.Subtitle,reuseIdentifier: cellid) } //设置每行现实标题 cell!.textLabel?.text=_dataArray![indexPath.row] //设置每行的副标题 cell!.detailTextLabel?.text=_dataSubtitleArray[indexPath.row] return cell! }
执行效果如下:
我们再尝试设置一下每行的图片
//设置图片 cell!.imageView?.image=UIImage(named: "tableimage");
执行效果如下
设置tableView右侧提示标签的样式
//设置右侧提示按钮 cell!.accessoryType=UITableViewCellAccessoryType.DetaildisclosureButton
看下效果
本节我们先讲到这里
下节地址:http://blog.csdn.net/lwjok2007/article/details/49179645
源码名称:TestTableViewSwift2.zip
苹果开发群2 :492222303 欢迎加入 欢迎讨论问题
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。