在Swift中单击Table View的单元格时如何调用(显示)另一个View Controller [英] How to call (show) another View Controller when clicked on the cell of Table View in Swift

查看:258
本文介绍了在Swift中单击Table View的单元格时如何调用(显示)另一个View Controller的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Swift的新手。我想学习如何在用户单击表格视图的单元格时调用另一个视图控制器。
预先感谢。

I'm new in Swift. I want to learn that, how to call another View Controller when the user clicks on cell of Table View. Thanks in advance.

推荐答案

在First View Controller中

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!)
{
   if segue.identifier == "showItemDetail" 
   {
    let indexPath:NSIndexPath = self.tableView.indexPathForSelectedRow()!
    let destination = segue.destinationViewController as DetailViewController
    destination.name = "llkin Elimov"
}

在第二个Detail View Controller中

public DetailViewController
{
    var name = "name" as String //After you created the segue in      main.storyboard, in name , you will get your parsed string automatically

}

希望我的代码对您很清楚:)

Hope my code is clear for you :)

这篇关于在Swift中单击Table View的单元格时如何调用(显示)另一个View Controller的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆