我有两个数组Data1和Data2,我希望将这些数据中的数据(它们包含字符串)填充到两个不同部分的tableview中.第一部分应标题为"Some Data 1",第二部分标题为"KickAss".
我有两个部分填充第一个数组的数据(但没有标题).
到目前为止,这是我的代码:
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 2
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
var rowCount = 0
if section == 0 {
rowCount = Data1.count
}
if section == 1 {
rowCount = Data2.count
}
return rowCount
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
let ip = indexPath
cell.textLabel?.text = Data1[ip.row] as String
return cell
} …Run Code Online (Sandbox Code Playgroud)