相关疑难解决方法(0)

swift中一个视图上的两个表

我有以下代码显示从一个视图中的两个不同数组填充的两个表:

@IBOutlet var RFTable: UITableView
    func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {

    }
    override func viewDidLoad() {
        super.viewDidLoad()

        self.RFTable.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")
    }
    func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
        return self.RFArray.count;
    }
    func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) ->     UITableViewCell! {
        var cell:UITableViewCell = self.RFTable.dequeueReusableCellWithIdentifier("cell") as     UITableViewCell

        cell.textLabel.text = String(self.RFArray[indexPath.row])

        return cell
    }

    @IBOutlet var IMProdTable: UITableView
    func tableView2(IMProdTable: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!)     {

    }
    override func viewDidLoad() {
        super.viewDidLoad()

        self.IMProdTable.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell2")
    }
    func tableView2(IMProdTable: UITableView!, numberOfRowsInSection …
Run Code Online (Sandbox Code Playgroud)

uitableview swift ios8

7
推荐指数
2
解决办法
1万
查看次数

将两个表视图添加到Xcode中的主视图

我将两个Table View放在我的main.storyboard上.然后我为它们创建了两个新的.swift类文件:VideoTableViewController和LinkTableViewController.我如何链接这两个?看起来我可能做错了,因为我读过我需要将委托链接到表视图所在的View.我希望它链接到我为Table View创建的控制器.我要做的是并排放置两个列表,一个带有视频链接,另一个带有网络链接.我已经有了数组中的数据.我只需要将数据放入正确的表视图的单元格中.

我注意到我可以将一个Table View Controller放到故事板上,但我不认为这就是我想要的,因为它是一个完全不同的视图.我希望这些看法是一致的.

VideoTableViewController:

import Foundation
import UIKit

class VideoTableViewController: UITableViewController {
@IBOutlet weak var videoTable = UITableView()

var videos: [Video] = []

override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!  {

    //disable header
    tableView.contentInset = UIEdgeInsetsMake(-30, 0, -20, 0);

    var cell : UITableViewCell = tableView.dequeueReusableCellWithIdentifier("Component") as UITableViewCell

    if (cell == nil) {
        cell = UITableViewCell(style: UITableViewCellStyle.Value1, reuseIdentifier: "Component")
    }

    //cell.textLabel.text = "Baking Soda"
    //cell.detailTextLabel.text = "1/2 cup"

    return cell
}

override func numberOfSectionsInTableView(tableView: UITableView!) -> …
Run Code Online (Sandbox Code Playgroud)

xcode uitableview ios swift

3
推荐指数
1
解决办法
9338
查看次数

标签 统计

swift ×2

uitableview ×2

ios ×1

ios8 ×1

xcode ×1