相关疑难解决方法(0)

如何使用swift在tableview中使用两个不同的数组填充两个部分?

我有两个数组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)

arrays uitableview sections swift

29
推荐指数
3
解决办法
6万
查看次数

标签 统计

arrays ×1

sections ×1

swift ×1

uitableview ×1