弹出和刷新视图控制器 [英] pop and refresh viewcontroller

查看:24
本文介绍了弹出和刷新视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个视图控制器.当我到达第三个视图控制器时,我使用 poptorootviewcontroller 弹出到我的第一个视图控制器,但是当我在第三个视图控制器中使用 popviewcontroller 时(我想回到我的第二个视图控制器)它会弹出但是我在我的第二个视图控制器在那里,我希望第二个视图控制器是新的(重置这个视图控制器),就像这个视图控制器被重新加载一样.这是我在第三个视图控制器中的代码:

I have three viewcontroller. when I get to the third viewcontroller, I use poptorootviewcontroller to pop to my first view controller, but when I use popviewcontroller in my third viewcontroller (i want to go back to my second viewcontroller) its poping but all the info that I edit in my second viewcontroller are there, and I want the secondviewcontroller to be new (reset this viewcontroller), like this viewcontroller to be reloaded. here is my code in the third viewcontroller:

-(IBAction)playAgain:(id)sender
{
   [self.navigationController popViewControllerAnimated:YES];
}

我该怎么做?谢谢!

推荐答案

在第二个viewcontroller中,你应该写一个方法viewWillAppear,如下所示,

In the second viewcontroller, you should write a method viewWillAppear like below,

-(void) viewWillAppear:(BOOL)animated
{
     [super viewWillAppear:animated];
     //set initial values here  
}

这个方法会在你的控制器即将出现时调用.所以当第三个视图控制器被弹出时,这个方法将被调用,你可以重置值.

This method will call when your controller is about to appear. So while third viewcontroller will get popped, this method will get called and you can reset values.

这篇关于弹出和刷新视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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