在使用 ARC 时,我的旧 UIWebViews 似乎仍然存在,出于某种原因,即使在我退出他们的 UIViewController 之后,它们仍然出现在 OSX Safari 的开发者工具中。
我正在为包含 UIWebView 的视图控制器分配转换,如下所示:
//Create settings view/tabbar
UITabBarController *tabController = [[NoRotateTabBarController alloc] init] ;
StyleViewController *styleTab = [[StyleViewController alloc] initWithNibName:@"StyleViewController" bundle:nil];
styleTab.tabBarItem.title = @"Style";
styleTab.tabBarItem.image = [UIImage imageNamed:@"EyeIcon.png"];
NSArray *tabsArray = @[styleTab];
tabController.viewControllers = tabsArray;
prevView = self.window.rootViewController;
[UIView
transitionWithView:self.window
duration:0.5
options:UIViewAnimationOptionTransitionFlipFromRight
animations:^(void) {
BOOL oldState = [UIView areAnimationsEnabled];
[UIView setAnimationsEnabled:NO];
self.window.rootViewController = tabController;
[UIView setAnimationsEnabled:oldState];
}
completion:nil];
我从这样的观点中走出来:
[UIView
transitionWithView:self.window
duration:0.5
options:UIViewAnimationOptionTransitionFlipFromLeft
animations:^(void) {
BOOL oldState = [UIView areAnimationsEnabled];
[UIView setAnimationsEnabled:NO];
self.window.rootViewController = prevView;
[UIView setAnimationsEnabled:oldState];
}
completion:nil];
UIWebView (int StyleViewController) 是这样创建的:
@implementation StyleViewController
UIWebView *webView;
//viewDidLoad
webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 1)];
webView.scalesPageToFit = NO;
webView.scrollView.scrollEnabled = false;
webView.multipleTouchEnabled = false;
webView.alpha = 0;
webView.backgroundColor = [UIColor clearColor];
webView.opaque = false;
@end
但是,我注意到,当我在 Safari 中进行检查时,旧的 UIWebViews 似乎在堆积,而旧的 UIWebViews 仍然显示在菜单中。这是 Safari 开发者工具中的错误吗?有没有办法确保我的 UIWebViews 被释放?