Swift练习一: 使用TableView展示数据
来源:互联网 发布:淘宝自动充值 编辑:程序博客网 时间:2024/04/30 08:10
今天看了一会Swift的学习资料,了解了一些Swift的基本语法和特性,写了一个小程序,展示系统字体,里面包含:
1)声明属性
2)let,var修饰符的作用
3)?,!代表什么,注意事项
4)集合类数组的使用
5)函数的使用(Swift里称函数)
import UIKitclass ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource { var dataAry : Array<String> = [] override func viewDidLoad() { super.viewDidLoad() self.loadData() let table = UITableView(frame: CGRectMake(0, 20, self.view.frame.size.width, self.view.frame.size.height-20)) table.delegate = self table.dataSource = self self.view.addSubview(table) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } func loadData() -> Void { dataAry = UIFont.familyNames() } func tableView(tableView:UITableView, numberOfRowsInSection section: Int) -> Int{ return dataAry.count } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = UITableViewCell(style:.Default, reuseIdentifier:"myCell") cell.textLabel?.text = dataAry[indexPath.row] cell.textLabel?.font = UIFont.init(name: dataAry[indexPath.row], size: 15) return cell } func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { return 60 }}
0 0
- Swift练习一: 使用TableView展示数据
- swift+tableview+数据展示
- 用swift实现tableview的展示
- tableView展示数据的过程
- iOS TableView 使用(swift)
- swift- tableView 的使用
- swift-tableview使用
- tableView 使用注意事项:一个tableView展示不同的cell时复用,以及数据更新
- 使用Playground快速练习Swift语法 (一)
- echarts 图表展示 练习一 (基础页面加载数据)
- swift中tableview的使用
- 封装展示没有数据的tableview
- 06-UI-TableView展示数据三部曲”
- Swift初窥--使用Swift实现TableView
- swift练习一
- ios TableView那些事2(Swift 一) 初见TableView
- tableView的使用(一)
- Swift练习小demo tableView 自定义cell 简单实用
- java split
- Nginx配置文件nginx.conf中文详解
- MVC过滤器详解
- hdu1171-01背包
- cnpm 安装
- Swift练习一: 使用TableView展示数据
- PHP脚本执行效率性能检测之WebGrind的使用
- Q1010 Tempter of the Bone C++ (深度优先搜索)
- velocity基础教程--3用velocity代替jsp作为程序视图展示
- Android项目笔记六:自定义的wificlass
- iOS开发笔记--使用blend改变图片颜色
- android studio运行直接进入了上次打开的项目,没有第一次打开的选择窗口
- Cordova之Android环境搭建
- Collections类方法的简单使用