pop and refresh viewcontroller

夙愿已清 提交于 2019-12-22 17:42:11

问题


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];
}

how can I do it? thanks!


回答1:


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.



来源:https://stackoverflow.com/questions/11384889/pop-and-refresh-viewcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!