Updating TableView within containerview

旧巷老猫 提交于 2019-12-11 09:28:52

问题


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:

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?


回答1:


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.



来源:https://stackoverflow.com/questions/43414625/updating-tableview-within-containerview

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!