IOS 查看委托以及何时调用它们

发布于 2024-12-11 00:42:36 字数 455 浏览 0 评论 0原文

我有一个 iPhone 应用程序,具有三个视图:切换器视图、数据采集视图和数据摘要视图。当应用程序启动时,将调用切换器视图的 viewDidLoad 委托,然后调用数据采集视图的 viewDidLoad 委托两次,然后调用 viewWillDisappear 并释放数据采集视图。这两个调用都源自我的切换器视图中的同一行代码,即当我为数据采集视图调用 insertSubView 时。一种调用来自 UIViewController,另一种调用来自 UINib,后者也由 UIViewController 调用。这有什么意义吗?

然后,当我接受用户输入来更改视图时,不会调用数据获取视图的 viewWillDisappear 委托。我刚刚收到数据摘要视图的 viewDidLoad 调用。

我很困惑。我正在尝试使用 viewWillDisappear 从数据采集视图中写出数据,然后可以将其读入数据摘要视图,但鉴于此序列,它不起作用。

有什么想法吗?

I have an iPhone app with three views, a switcher view, a data acquisition view, and a data summary view. When the app starts up, the viewDidLoad delegate for the switcher view is called, and then the viewDidLoad delegate for the data acquisition view is called TWICE, followed by a viewWillDisappear call and a dealloc for the data acquisition view. Both calls originate from the same line of code in my switcher view which is when I invoke insertSubView for the data acquisition view. One call is from UIViewController and one is from UINib which is also called by UIViewController. Does this make any sense?

Then, when I take user input to change views, the viewWillDisappear delegate for the data acquisition view is NOT called. I just get the viewDidLoad call for the data summary view.

I'm confused. I am trying to use viewWillDisappear to write out data from the data acquisition view that can then be read into the data summary view, but given this sequence it doesn't work.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

俯瞰星空 2024-12-18 00:42:36

解决您最后/主要关心的问题。否 [DataAcquisitionView viewWillDisappear] 不是填充 SummaryView 的位置。当您完成加载数据后,您应该明确创建您的summaryView,然后用您需要总结的内容填充它的视图,然后呈现它。

根据您的新信息:

您想要使用 tabBarController 委托方法;

-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
    NSLog(@"Switch views");
}

这将告诉您我们用户选择了不同的 viewController,您可以处理该事件。

To address what seems to be your last/main concern. NO [DataAcquisitionView viewWillDisappear] is not where to populate your SummaryView. When you finish loading you data you should then expressly create your summaryView, then populate it views with whatever you need to summarize, and then present it.

Based on you new information:

You want to use the tabBarController delegate method;

-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
    NSLog(@"Switch views");
}

That will tell you we the user has selected a different viewController you can the handle that event.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文