简体   繁体   English

在UITabBarController中的屏幕之间共享信息

[英]Sharing information between screens in UITabBarController

I have UITabBarController, containing 2 screens - A,B. 我有UITabBarController,包含2个屏幕-A,B。 I also have a strings array - strArr in my application delegate (this array is a global variable). 我也有一个字符串数组-我的应用程序委托中有strArr(此数组是全局变量)。

Screen A changes strArr. 屏幕A更改strArr。 Screen B contains UIPickerView that displays the values from strArr. 屏幕B包含UIPickerView,它显示strArr中的值。

The problem: When I see screen B, I can see the updated values from the strArr array in the picker. 问题:当我看到屏幕B时,可以在选择器的strArr数组中看到更新的值。 BUT, after I'm changing the values of strArr in Screen A, switching to screen B and watching the spinner, I still see the old values, and the app crashes when I'm selecting non-existing anymore item from the picker... 但是,在屏幕A中更改strArr的值,切换到屏幕B并查看微调器之后,我仍然看到旧值,并且当我从选择器中选择不再存在的项目时,应用程序崩溃。 。

The question (You've probably already know what I'm about to ask..): How can I display the updated values in the picker that located on screen B? 问题(您可能已经知道我要问的问题了。):如何在屏幕B的选择器中显示更新的值?

Thanks all. 谢谢大家

如果您的数据模型的一部分发生了变化,而应用程序的其余部分需要了解它,则可以使用键值观察通知

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在UITabBarController中的UIViewController之间共享UIView - Sharing a UIView between UIViewControllers in a UITabBarController iPhone OS:在UITabBarController中的ViewControllers之间共享UIWebView - iPhone OS: Sharing a UIWebView between ViewControllers in a UITabBarController 在UITabBarController xcode中的UIViewController和UIViewController之间共享数据 - sharing Data between a UIViewController and a UIViewController in UITabBarController xcode 如何在UITabBarController中的两个UIViewControllers之间传递信息 - How to pass information between two UIViewControllers in a in a UITabBarController 在类之间共享结构信息-目标C-OpenGL ES - Sharing Struct Information Between Classes - Objective C - OpenGL ES uitabbarcontroller - 跳转到 uiviewcontroller - uitabbarcontroller -jump between to uiviewcontroller 在移动网络应用程序和iPhone上的移动应用程序之间共享信息 - Sharing information between mobile web app and mobile app on iPhone 在UITabBarController和UINavigationController之间切换 - Switch between UITabBarController and UINavigationController UITabBar和UITabBarController有什么区别? - What is the difference between UITabBar and UITabBarController? 在UITabBarController / UIViewControllers之间移动值 - Move a value between UITabBarController /UIViewControllers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM