ios TableView那些事2(Swift 二) 初见TableView Grouped
来源:互联网 发布:ubuntu命令行调整音量 编辑:程序博客网 时间:2024/05/16 16:08
今天让我来创建个简单的Grouped
一
import UIKit
class ViewController: UITableViewController {
let dataScoureArray:[String] = ["A","B","C","D","E","F","G","H"]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
//cell Number
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
return dataScoureArray.count;
}
//section Number
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 2
}
//creat Cell
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
let cell:UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier:"cell");
cell.textLabel.text = dataScoureArray[indexPath.row]
return cell;
}
//set Footer Height
override func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 20;
}
//set Header Height
override func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 20;
}
//set Header Title
override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return "Hello"
}
//set Footer Title
override func tableView(tableView: UITableView, titleForFooterInSection section: Int) -> String? {
return "World"
}
//set Cell Row Height
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 50;
}
//cell DidSelectAction
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
}
(二)在实际中我们要定制自己的tableview head 或footer
// 在tableview 的headView 上添加个view 其实你可以在这个view 加很多组件 在添加在HeadView
override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?{
var view:UIView = UIView(frame: CGRectMake(0, 0,self.view.frame.size.width, 20));
view.backgroundColor = UIColor.yellowColor();
return view;
}
//在footerView 添加个button
override func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView?{
let myButton:UIButton = UIButton(frame: CGRectMake(0, 0, self.view.frame.size.width, 20));
myButton.setTitle("I am a Button", forState: UIControlState.Normal);
myButton.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal);
myButton.backgroundColor = UIColor.greenColor();
return myButton;
}
- ios TableView那些事2(Swift 二) 初见TableView Grouped
- ios TableView那些事2(Swift 一) 初见TableView
- ios tableView那些事(二)给tableView添加数据
- ios tableView那些事(二)给tableView添加数据
- ios TableView那些事3(Swift 三) TableView 的删除操作
- ios tableview 那些事(二十五)用故事板 自定义Tableview 不显示数据注意事项。
- ios tableview 那些事(二十七)tableview 下滑手势关闭键盘
- ios TableView那些事(三十 二)Tableview一直显示滚动条
- tableview——Grouped
- iOS TableView 使用(swift)
- ios swift tableview
- ios tableView那些事 (五) 给tableview设置缩进级别
- ios tableView那些事 (七) 给tableView添加响应事件
- ios tableView那些事 (八) tableview的插入移动
- ios tableView那些事 (九) tableview的删除
- ios tableView那些事 (十)设置 tableview 的分割线
- ios tableView那些事 (十二) 给 tableview 加个长按快捷菜单
- ios tableView那些事 (十三) 给 tableview 添加索引
- No result defined for action and result input
- 程序员怎能不知道什么是数据挖掘
- java-重载,构造函数,匿名对象
- Windows常见数据类型及变量_常量命名规律
- 分支-03. 三天打鱼两天晒网(15)
- ios TableView那些事2(Swift 二) 初见TableView Grouped
- [C++] 变量、指针、引用作函数参数的区别
- UVa 10490 - Mr. Azad and his Son!!!!!
- 分支-04. 出租车计价(15)
- C语言小结
- 分支-05. 用天平找小球(10)
- 解决java闭包函数内变量离开闭包函数后无法获取到最终值
- MFC框架程序剖析
- fine/coarse grain 多线程实践