ios - 在 containerview 中更新 TableView

标签 ios swift3

我有我的 UIViewController ,这是一个人的个人资料页面,它显示他们的姓名和照片。其中UIViewController我有一个 UIContainerView显示静态 UITableView .加载配置文件页面时,我在更新表格的单元格时遇到了一些问题。这是我的 Storyboard:

enter image description here

我在我的 UIViewController 中尝试了以下方法.

我为我的 UIView 创建了一个导出。并将 person 对象传递给它。

在我的 UIView我调用 segue 将对象传递给 UITableViewController从那里我要更新一些标签。

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

我的 Segue 从来没有被调用过。我已将其移至主 UIViewController万一它应该从那里被调用,但又不被调用。这种方法我做错了什么?

最佳答案

假设您已将 Segue Identifier 设置为“containerSegue”,您应该在“Stats” View Controller 中获取它。

你在使用 Swift 3 吗?您可能只是 func 定义错误:

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

那应该行得通。

关于ios - 在 containerview 中更新 TableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43414625/

相关文章:

ios - Swift如何实时替换UITextView文本的多个字符?

iphone - 如何在顶部 viewForHeaderInSection 上添加一个 UIButton

ios - ReplayKit 和预览的标题

ios - iMessage 应用程序 - 以编程方式从 .apng 创建动画贴纸

swift - 在 willDisplay 中配置自调整大小的单元格

ios - 如何在类型扩展方法中实例化类型?

ios - 查询子数组中的对象

ios - 为什么我不能在 Swift 中将对象数组返回给 UIStackView?

swift - 将 nil 作为 UnsafePointer<UInt8> 传递

ios - 在应用程序运行后,是否可以在 ui 测试中以编程方式将应用程序移动到 Split View/ slider 上方的 View ?