【问题标题】:Swift / tableView pass data with instantiateViewControllerWithIdentifierSwift / tableView 使用 instantiateViewControllerWithIdentifier 传递数据
【发布时间】:2016-07-26 22:00:34
【问题描述】:

我在 tableView 中填充了 BackendlessUsers 数组。如何在 didSelectRowAtIndexPath 函数中传递用户?

var deejays: [BackendlessUser] = []

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

    print("You selected cell #\(indexPath.row)!")
    self.tableView.deselectRowAtIndexPath(indexPath, animated: true)

    **let user = deejays[indexPath.row]**
    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let vc = storyboard.instantiateViewControllerWithIdentifier("DJProfileAsUserVC") as! DJProfileAsUserVC

    dispatch_async(dispatch_get_main_queue()) {
        self.presentViewController(vc, animated: true, completion: nil)
    }
}

非常感谢您的帮助。

【问题讨论】:

    标签: ios swift backendless


    【解决方案1】:

    在 DJProfileAsUserVC 中创建一个 var 用户:DJProfileAsUserVC!,然后到此:

    let user = deejays[indexPath.row]
    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let vc = storyboard.instantiateViewControllerWithIdentifier("DJProfileAsUserVC") as! DJProfileAsUserVC
    vc.user = user
    

    【讨论】:

    • @property 快速? ://
    • 完成。如果这是您想要的,请告诉我。
    猜你喜欢
    • 2013-03-27
    • 1970-01-01
    • 1970-01-01
    • 2017-02-10
    • 1970-01-01
    • 1970-01-01
    • 2015-03-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多