swift中表视图的创建
来源:互联网 发布:如何自学matlab知乎 编辑:程序博客网 时间:2024/05/11 13:04
//// ViewController.swift// myview//// Created by 黄权浩 on 14-12-27.// Copyright (c) 2014年 黄权浩. All rights reserved.//import UIKitclass ViewController: UIViewController,UITableViewDelegate, UITableViewDataSource{//tableView的协议(在swift中你必须实现协议中的必实现协议,否则编译器会报错) override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. //声明一个变量它的类型是表视图 并且初始化了它的fram var mytableView = UITableView(frame: CGRect(x: 0, y: 0, width: 320, height: 568)) //实现tableView的协议 mytableView.delegate = self mytableView.dataSource = self self.view .addSubview(mytableView)//加入当前视图控制器 } //表视图协议方法 func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int{ return 20; }//表视图的返回行数 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{ let CellId="my cell";//cell标识符 var cell = tableView.dequeueReusableCellWithIdentifier(CellId) as? UITableViewCell;//创建cell if(cell==nil) { cell=UITableViewCell(style:.Default,reuseIdentifier:CellId); } //其实跟oc完全是大同小异 cell?.textLabel?.text = "\(indexPath.row)"//附值 return cell!; } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. }}
0 0
- swift中表视图的创建
- MySQL中表的创建
- Oracle数据库中表与视图的应用
- Oracle数据库中表与视图的应用
- Oracle数据库中表与视图的应用
- SQL中表与视图的区别
- 用swift创建根视图
- 在OC代码中创建Swift编写的视图控制器
- Android中的sqlite中表的创建
- Android中的sqlite中表的创建
- MySQL中表创建失败的原因之一
- ORACLE中表空间的创建与删除
- 查看中表、视图等
- 数据库中表和视图的区别和联系
- 数据库中表和视图的区别和联系
- Swift中tableView加载通过xib创建的headerView时,无法显示xib视图内容.
- hive中表的创建以及数据的加载
- 表视图的创建
- WebService学习系列(三)------XML-RPC
- python V2.7.6 Documentation Built-in Functions
- 上传多个文件直接把内容转存到本地
- Qt隐式/显式调用DLL
- vs2013解决方案资源管理器怎样靠左
- swift中表视图的创建
- c++学习笔记(02)
- 支付宝抢先微信推海外移动端汇款服务
- Java基础----HashSet
- gdb调试内核(整理)
- What are the benefits of PreparedStatement over Statement
- 二三维联动技术总结
- iCloud开发--Using CloudKit Dashboard to Manage Databases
- 各种问题的理解