简体   繁体   English

viewDidAppear正在运行,然后没有运行。

[英]viewDidAppear running, and then not running.

In my ios app, I begin by loading the SecondViewController using the code shown below. 在我的ios应用程序中,我首先使用下面显示的代码加载SecondViewController。 When that view controller appears, I also run viewDidAppear as shown in the code snippet below. 当该视图控制器出现时,我还运行viewDidAppear,如下面的代码片段所示。 That works ok. 这没问题。 From there, I load my FifthViewController and do some calculating which needs to be returned to the SecondViewController. 从那里,我加载我的FifthViewController并做一些计算,需要返回到SecondViewController。 Unfortunately, when I return to SecondViewController via the same exact method, the viewDidAppear method does not run. 不幸的是,当我通过相同的方法返回到SecondViewController时,viewDidAppear方法不会运行。 Any suggestions on how to fix that would be appreciated. 任何关于如何解决这个问题的建议都将受到赞赏。

-(IBAction) loadSecondView:(id)sender
{


NSLog(@"In loadSecondView method \n");

[secondViewController viewDidAppear:YES];

[self clearView];
[self.view insertSubview:secondViewController.view atIndex:1];

}

If you want something to be performed every time after dismissing a viewcontroller, you should use delegate method. 如果您希望在解除视图控制器后每次都执行某些操作,则应使用委托方法。 It is much more specific than viewDidAppear or viewWillAppear. 它比viewDidAppear或viewWillAppear更具体。

Here's a website where you can get started. 这是一个可以开始使用的网站

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM