小编O.O*_*ier的帖子

单击 UITableViewCell 时执行操作

我正在为 Apple TV 制作 tvOS 应用程序,但我的UITableView. 当我点击一个UITableViewCell什么都没有发生。我正在使用,targetForAction但它似乎不起作用。

这是我的代码:

override func viewDidLoad() {
    super.viewDidLoad()

    self.tableView.dataSource = self
    self.tableView.delegate = self
}

let allData = ["Los Angeles","New York","San Fransisco"]

@IBOutlet weak var tableView: UITableView!

func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    return 1
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return allData.count
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = UITableViewCell(style: .Default, reuseIdentifier: nil)
    cell.textLabel?.text = "\(allData[indexPath.row])"
    cell.targetForAction("buttonClicked:", withSender: …
Run Code Online (Sandbox Code Playgroud)

uitableview swift swift2 tvos

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

标签 统计

swift ×1

swift2 ×1

tvos ×1

uitableview ×1