gpt4 book ai didi

ios - 在模拟内存警告期间销毁 View

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:03:36 27 4
gpt4 key购买 nike

我正在读一本书,其中有一个带有两个选项卡的 UITabBarController。一个时间标签和另一个催眠标签。 Time 选项卡显示一个 TimeViewControllerHypnosis 选项卡显示一个 HypnosisViewController

这是 TimeViewController 的实现:

- (void)viewDidUnload
{
[super viewDidUnload];
NSLog(@"Unloading TimeViewController's subviews");
timeLabel = nil;
}

书上说如果我在Hypnosis 选项卡上模拟内存警告,我应该看到上面输入的日志消息。但是,这不会发生。有谁知道为什么?我正在使用 iOS 6.1 模拟器和最新的Xcode(尽管这本书是关于 iOS 5 的)。

最佳答案

在新版本中已弃用,您应该使用;

didReceiveMemoryWarning

来自苹果:

In iOS 6, the viewWillUnload and viewDidUnload methods of UIViewController are now deprecated. If you were using these methods to release data, use the didReceiveMemoryWarning method instead. You can also use this method to release references to the view controller’s view if it is not being used. You would need to test that the view is not in a window before doing this.

关于ios - 在模拟内存警告期间销毁 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17807888/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com