填充嵌入式 UITableViewController [英] Populating an embedded UITableViewController

查看:25
本文介绍了填充嵌入式 UITableViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用导航控制器的应用.在其中一个视图中,我有一个使用静态单元格嵌入 UITableViewController 的视图容器.我需要使用从前一个视图传入的数据填充此表视图控制器的标签.流程如下

I have an app using a navigation controller. In one of the views, I have a view container with an embedded UITableViewController using static cells. I need to populate this table view controller's labels with data passed in from a previous view. The flow is as follows

View1 > segue-> Parent>Child

View1 > segue-> Parent>Child

我需要将数据从 View1 传递给 Child.对此进行测试时,似乎 Child 的 viewDidLoad 在 Parent 的 viewDidLoad 之前触发.这对我来说似乎不合逻辑.在 Child 上使用 viewDidAppear 有效,但更新标签存在延迟,这实际上是不可接受的.

I need to pass data from View1 to Child. When testing this, it appears that Child's viewDidLoad fires BEFORE Parent's viewDidLoad. This doesn't seem logical to me. Using viewDidAppear on the Child works, but there is latency in updating the labels, which isn't really acceptable.

任何人都可以阐明如何在加载其父级时更新嵌入式 UITableViewController?

Can anyone shed light on how to update an embedded UITableViewController when its parent is loaded?

谢谢!

推荐答案

在prepareForSegue中将数据传递给父级,在viewDidLoad(父级的)中将字符串传递给子级.在子组件中,在 viewWillAppear: 中使用此字符串设置其标签的值.

Pass the data to the parent in prepareForSegue, and in viewDidLoad (of the parent) pass the string to the child. In the child, set the value of its label with this string in viewWillAppear:.

这篇关于填充嵌入式 UITableViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆