当前位置: 动力学知识库 > 问答 > 编程问答 >

ios - Connecting a cell of array in a view created in the main storyboard

问题描述:

I used the ExpandTableView of this repository on Github:

Repo -> https://github.com/SubhiH/ExpandableTableView

I need know how i connect a position of the array of this expandable view in a View in the Main storyboard, example:

Image of the ExpandableTableView

I want that when a User click for example in the cell a1 user is sent to a TableView (View) on Main storyboard.

Any ideas?

网友答案:

I think you are looking for the function func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath), that you already implemented in ExpandableTableViewViewController.swift.

There, you can add a segue to your Main View Controller, passing it the data.

if let resultController = storyboard!.instantiateViewControllerWithIdentifier("IDOfYourMainView") as? ResultViewController {
    //Here you can access to the view's functions and attributes. 
    //You can set, for example, an imageView and set it the image you want. 
    //Then, when the view loads (Read next line), it should have your image loaded.
    presentViewController(resultController, animated: true, completion: nil)
}
分享给朋友:
您可能感兴趣的文章:
随机阅读: