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

时间:2016-08-31 17:35:47

标签: ios objective-c swift uitableview swift2

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?

1 个答案:

答案 0 :(得分:1)

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)
}