如何在uinavigationcontroller中调用viewdidload? [英] how to not call viewdidload in uinavigationcontroller?

查看:82
本文介绍了如何在uinavigationcontroller中调用viewdidload?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找解决我的情况的方法。我的应用程序如下:

I am looking for a solution to my situation. My app is as followed:

在VC1上有一个文本字段和按钮。用户键入名称。然后单击一个按钮。这个按钮打开VC2。用户在VC2中提供附加信息,然后按保存。我使用segue返回VC1并将这些附加信息作为字符串传输到VC1。但是在VC1中,viewdidload已经调用并且由于文本字段中的信息被删除了!如何在不调用viewdidload的情况下在VC之间导航?

On VC1 there is a textfield and button. User types a name. Then click on a button. This button open VC2. User gives additional information in VC2 then press save. I used a segue to go back to VC1 and transfer those additional information as a string to VC1. But in VC1 viewdidload has called and due to that information in the textfield is deleted!!! How can I navigate between VC without recalling viewdidload?

我找到了一些有关单例对象的信息。如果我可以在一段时间内定义一个活着的物体,那么我会通过风险投资。如何让一个具有多个字段的对象一直处于活动状态。

I found some information about singleton objects. If I can define an object which is alive during time I go through VCs would be great. How can I have an object with multiple fields and alive all the time.

推荐答案

我担心你为什么要使用push segue后退。

I am afraid that why you are using push segue to move back.

在这里,您需要协助从VC-A推送到VC​​-B并将其标识符命名为moveForward和button press call

Here you need to assing a push segue from VC-A to VC-B and name its identifier like moveForward and button press call

[self performSegueWithIdentifier:@"moveForward" sender:self]; 

如果您想要传递给VC-B的任何信息在此方法中传递

and if any information u want to pass to VC-B pass it in this method

 - (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
   {
    if([segue.identifier isEqualToString:@"moveForward"])
    {
        VC-B* vcObject=[segue destinationViewController];

        //vcObject.info = your info//etc
    }
   }

同样,当您必须从VC-B返回VC-A时,将VC-B的倒带segue指定为VC-A,并将其标识符命名为moveBack,并按下按钮
并在VC-B中执行上述方法。

In a same way when u have to return to VC-A from VC-B assign a rewind segue from VC-B to VC-A and name its identifier like moveBack and on button press and do the above mention method in VC-B too.

这篇关于如何在uinavigationcontroller中调用viewdidload?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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