将数据从UIViewController传递回1个UIViewController [英] Passing data from UIViewController to 1 back UIViewController

查看:49
本文介绍了将数据从UIViewController传递回1个UIViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有这个UINavigationController,我是第一个移到下一个视图,而不是我想点击后退"按钮并返回到第一个视图,其中包含我保存到"strAddress"中的数据第二个观点.我想在"lblShowStr.text"的第一个视图上显示数据.

So I have this UINavigationController, I'm on the first moving to the next view, than I want to hit the 'back' button and to go back to the first view with the data that I saved into 'strAddress' on the second view. I want to present the data on the first view on 'lblShowStr.text'.

我如何做到这一点?我搜索了所有的网络,找到了一些写信的人,但是不明白那里告诉了他们什么.

how can I manage to do that? I've searched all the web, found some people that wrote, but couldn't understand what they have been told there.

谢谢!

推荐答案

在第一个视图控制器中,您可能具有名为strAddress的NSString属性.并在每次视图出现时将该字符串放入lblShowStr.text中.

In your first view controller you might have an NSString property called strAddress. and you put that string into lblShowStr.text every time the view appears.

在第二个视图控制器中,您可能具有指向一个视图控制器实例的属性.实例化第二个视图控制器时,可以将其上的属性分配给第一个视图控制器.

In your second view controller you might have a property pointing to an instance of view controller one. When you instantiate your second view controller you could assign the property on it to the first view controller.

secondViewController.firstViewController = self;或者[secondViewController setFirstViewController:self];

secondViewController.firstViewController = self; or [secondViewController setFirstViewController:self];

然后,当用户按下后退按钮viewDidAppear时,第一个视图将被调用并更新字符串.

Then when the user presses the back button viewDidAppear would get called for the first view and update the string.

我假设您不想将此数据存储在其他任何地方,例如在您的模型或nsuserdefaults等中.

I am assuming you don't want to store this data anywhere else e.g. in your model or nsuserdefaults etc.

这篇关于将数据从UIViewController传递回1个UIViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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