//
// ViewController2.swift
// swift_helloword
//
// Created by Charlie on 15/7/13.
// Copyright (c) 2015年 Json. All rights reserved.
// import Foundation
import UIKit class RootViewController: UIViewController,UITableViewDataSource,UITableViewDelegate { //协议 var tableView :UITableView? = UITableView( frame: CGRectZero, style: UITableViewStyle.Plain); override func viewDidLoad() {
configUI()
}
func configUI(){
tableView!.frame = CGRect (x: , y: , width: , height: )
self.view.addSubview(tableView!)
tableView!.delegate = self
tableView!.dataSource = self //设置代理 }
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return
}
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
var view:UIView = UIView (frame: CGRect (x: , y: , width: , height: ))
var la = UILabel (frame: view.frame);
la.backgroundColor = UIColor.greenColor()
la.text = "第\(section)+分区" //分区的名字
view.addSubview(la)
return view;
}
func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return ; //每一个分组的高度
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cellId:String = "id"
var cell = tableView.dequeueReusableCellWithIdentifier(cellId) as? UITableViewCell; //?是可选的 就是可能是nil
if cell == nil {
cell = UITableViewCell (style: UITableViewCellStyle.Default, reuseIdentifier: cellId)
}
cell?.textLabel?.text = String (indexPath.row )
return cell!// 返回cell 或者 nil
}
}

 

最新文章

  1. [原]HAproxy 代理技术原理探究
  2. iOS-推送,证书申请,本地推送
  3. 2.0(3)MongoDB数据导入导出
  4. 添加css的方式:link与@import区别
  5. Qt Style Sheet实践(三):QCheckBox和QRadioButton
  6. pt-heartbeat使用实践
  7. Spring.Net AOP实例
  8. cocos2d-x创建场景
  9. 《Windows驱动开发技术详解》之HelloDDK
  10. Java数组的一些使用方法及堆栈存储
  11. C3垂直居中均分
  12. Gym101138D Strange Queries/BZOJ5016 SNOI2017 一个简单的询问 莫队、前缀和、容斥
  13. 查看mysql的版本号
  14. setAttribute的浏览器兼容性(转)
  15. 彻底解决:java.sql.SQLException: Incorrect string value: '\xF0\x9F\x92\x94' for column 'name' at row 1
  16. python全栈开发day17-常用模块collections,random,time,os,sys,序列化(json pickle shelve)
  17. 【HAOI2012】容易题
  18. AI 实验--v_JULY_v
  19. 在ASP.NET MVC中使用Castle Windsor
  20. Codeforces Round #131 Div1 B

热门文章

  1. js问题学习
  2. 在ie中用滤镜 (filter:progid:DXImageTransform.Microsoft.gradient)会触发overflow:hidden?
  3. 以Ajax的方式访问数据库
  4. php正则提取img所有属性值
  5. Java 集合嵌套List of List
  6. 行业百科知识--Github
  7. 欧几里得求最大公约数--JAVA递归实现
  8. [问题解决] LaTex Error:Unknown graphics extension:.eps
  9. 转载:10 Easy Steps to a Complete Understanding of SQL
  10. mysql排行榜sql的实现