【发布时间】:2015-05-05 14:26:02
【问题描述】:
我是 swift 和面向对象编程的新手,
我正在尝试在我的 UI 表格视图的部分中显示一些日期
我想手动修改这些section的Header
这是我的代码:
let section1 =
["this is used tot test the lenght of the text",
"this is used tot test the lenght of the text",
"this is used tot test the lenght of the text",
"this is used tot test the lenght of the text",
"this is used tot test the lenght of the text",
"this is used tot test the lenght of the text",
"this is used tot test the lenght of the text",
"this is used tot test the lenght of the text",
"this is used tot test the lenght of the text",]
let section2 =
["this is used tot test the lenght of the text",
"this is used tot test the lenght of the text",
"this is used tot test the lenght of the text",
"this is used tot test the lenght of the text",
"this is used tot test the lenght of the text",
"this is used tot test the lenght of the text",
"this is used tot test the lenght of the text",
"this is used tot test the lenght of the text",
"this is used tot test the lenght of the text",]
然后是我的加载方法
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 5
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return self.section1.count;
}
func tableView(tableView: UITableView,
cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell:UITableViewCell = UITableViewCell(style:UITableViewCellStyle.Default, reuseIdentifier:"cell")
cell.textLabel!.text = section1[indexPath.row]
cell.textLabel!.numberOfLines = 3
return cell
}
我为这些创建了多个常量,但它们不需要分开(它们是常量,不会改变)
我的数据只需要 5 个不同的部分
非常感谢
【问题讨论】:
标签: uitableview sections