Jonnny
Jonnny

Reputation: 5039

Updating TableView within containerview

I have my UIViewController, which is a person's profile page, it displays their name and picture. Within that UIViewController I have a UIContainerView that displays a static UITableView. I'm having a little trouble updating the cells of the table when the profile page loads. Here's my storyboard:

enter image description here

I have tried the following, within my UIViewController.

I created an outlet to my UIView and passed the person object to it.

In my UIView I called the segue to pass the object to the UITableViewController and from there I was going to update some labels.

func prepareForSegue(segue: UIStoryboardSegue!, sender: Any?){
    if segue.identifier == "containerSegue"{
        let statsTable = segue.destination as! CollectionTableViewController
        statsTable.currentPerson = currentPerson
    }
}

My Segue is never called though. I have moved it to the main UIViewController in case it should be called from there, but again not called. What am I doing wrong with this approach?

Upvotes: 1

Views: 38

Answers (1)

DonMag
DonMag

Reputation: 77647

Assuming you have set the Segue Identifier to "containerSegue" you should get it in your "Stats" view controller.

Are you using Swift 3? It's possible you just have the func definition wrong:

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if segue.identifier == "containerSegue" {
        let statsTable = segue.destination as! CollectionTableViewController
        statsTable.currentPerson = currentPerson
    }
}

That should work.

Upvotes: 2

Related Questions