ios - 如何访问嵌入在容器 View 中的tableviewcontroller

标签 ios uitableview uicontainerview

我有一个带有 2 个 subview 的自定义 UIViewController“ProfileController”——最重要的是一个嵌入了 UITableViewController 的容器 subview 。我如何从“ProfileController”中访问 UITableViewController,以便我可以动态配置我用来显示用户配置文件信息的“静态”单元格。

我不想使用独立的 UITableViewController,因为那样我就无法向配置文件屏幕的 UI 添加额外的自定义项。谢谢!

...不幸的是,我无法在 Storyboard中为标准 UITableView 设计静态单元格,因为我发现 Apple 的静态单元格实现与 UITableViewController 紧密耦合。真可惜。

最佳答案

在您的 ProfileController 覆盖中:

override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!){
    if segue.identifier == "whateverYouNamedTheEmbedSegue"{
        myTableViewController = segue.destinationViewController as UITableViewController
    }
}

关于ios - 如何访问嵌入在容器 View 中的tableviewcontroller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23169984/

相关文章:

iphone - 在 iPhone sdk 中调整大小后获取图像的大小

ios - NSOperation 和 NSURLConnection 迷惑了

ios - 如何取消隐藏 UITableView 部分的动画?

ios-防止滚动时重新加载 UITableView 中的单元格

swift - 如何调整 subview Controller 的高度以匹配容器 View 的高度

ios - 无法缩放/缩放带有附加 SKPhysicsJoints 的 SKSpriteNode

iphone - 将 vcard 的文件类型与 iPhone 应用程序相关联

ios - 在 iOS 上将 editActionsForRowAtIndexPath 与 MoPub 结合使用

ios - 在容器 View 中刷新单 View Controller

objective-c - 使导航 Controller 在 iOS 6 和 iOS 7 中工作相同