【问题标题】:How to get onto another view from clicking on a table view cell如何通过单击表格视图单元格进入另一个视图
【发布时间】:2016-03-19 15:20:21
【问题描述】:

您好,我将如何点击一个 tableviewcell 来显示另一个视图。谢谢!

【问题讨论】:

  • 请详细说明您的问题并提供更多信息
  • 告诉 Xcode 创建一个新项目。选择主/详细模板。它可以满足您的要求,无需额外代码。

标签: ios swift swift2


【解决方案1】:

你需要的是使用didSelectRowAtIndexPath

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    let controller = //Init your controller here
    controller.data = //Pass any needed values to controller
    self.presentViewController(controller, animated: true, completion: nil) //Show your controller
}

您可以查看this tutorial了解更多信息。

【讨论】:

    【解决方案2】:

    使用这个didSelectRowAtIndexPath 方法。

    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        self.performSegueWithIdentifier("SEGUETOYOURVIEWCONTROLLERNAME", sender: self)
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-09-04
      • 1970-01-01
      • 1970-01-01
      • 2016-07-18
      • 2018-07-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多