在 iOS6 中不再调用 viewDidUnload,因此作为在 viewDidUnload 中执行一些必要操作的应用程序的解决方法,我已经这样做了:
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// only want to do this on iOS 6
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 6.0) {
// Don't want to rehydrate the view if it's already unloaded
BOOL isLoaded = [self isViewLoaded];
// We check the window property to make sure that the view is not visible
if (isLoaded && self.view.window == nil) {
// Give a chance to implementors to get model data from their views
[self performSelectorOnMainThread:@selector(viewWillUnload)
withObject:nil
waitUntilDone:YES];
// Detach it from its parent (in cases of view controller containment)
[self.view removeFromSuperview];
self.view = nil; // Clear out the view. Goodbye!
// The view is now unloaded...now call viewDidUnload
[self performSelectorOnMainThread:@selector(viewDidUnload)
withObject:nil
waitUntilDone:YES];
}
}
}
苹果拒绝这样的事情有先例吗?由于时间限制,我不能冒险让他们拒绝任何东西。