我在用故事板。正如我所记得的(我使用ios 4,长时间ago=),每次当视图出现时调用
-(void)viewWillAppear:(BOOL)Animated {}方法。现在这个方法不调用,如果我按下主页按钮,并再次运行应用程序。
怎么修呢?
我需要更新一个UIView,如果它出现后,在家按压。
发布于 2014-10-21 08:55:36
函数viewWillAppear不是UIView的一部分。它是UIViewController的一部分。
它是在视图控制器的视图被加载之后,在它开始转换到屏幕之前调用的。
如果您创建了一个UIView的子类并将这个函数放入其中,那么它将永远不会被调用,因为它不应该被调用。
编辑
当应用程序从后台返回时,viewWillAppear没有被调用,这是正确的。
如果您想在发生这种情况时更新应用程序的一部分,那么您可以在AppDelegate中做一些事情。
我建议不要试图存储财产等等..。不过,在AppDelegate。你应该这样做..。
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
// just pass the message on. In your view you will need to add an observer for this notification
[[NSNotificationCenter defaultCenter] postNotificationName:@"UpdateViewNotification" object:nil];
}发布于 2014-10-21 08:51:49
试试这个,打电话给上级,
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}https://stackoverflow.com/questions/26482519
复制相似问题