1
我試圖插入一個Cordova CleaverView(CDVViewController)到一個UIViewController(SenchaViewController)從一個故事板實例化爲了呈現一個基於JavaScript Sencha的視圖。CDVViewController仍然在父母被刪除後執行JS
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if (![ self.slidingViewController.underLeftViewController isKindOfClass:[MenuViewController class]]) {
self.slidingViewController.underLeftViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Menu"];
}
self.view.layer.shadowOpacity = 0.75f;
self.view.layer.shadowRadius = 10.0f;
self.view.layer.shadowColor = [UIColor blackColor].CGColor;
CDVViewController *cdvc = [CDVViewController new];
cdvc.wwwFolderName = @"www";
cdvc.startPage = @"sencha.html";
cdvc.useSplashScreen = NO;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
cdvc.view.frame = CGRectMake(0, 0, 768, 1004);
} else {
cdvc.view.frame = CGRectMake(0, 0, 320, 460);
}
[self.view addSubview:cdvc.view];
[self.view bringSubviewToFront:self.menuButton];
[self.view bringSubviewToFront:self.favButton];
cdvc = nil;
NSString *jsSetIdString = [NSString stringWithFormat:@"fetchGuid = function(){return '%@';}", [player valueForKey:@"playerID"]];
[[cdvc webView] stringByEvaluatingJavaScriptFromString:jsSetIdString];
[self.view addGestureRecognizer:self.slidingViewController.panGesture];
}
我的問題是之後我刪除了父視圖控制器(SenchaViewController),它擁有CDVViewController的看法例如,CDVViewController沒有得到釋放,並仍在運行背景,因爲我仍然可以看到控制檯中的JavaScript日誌記錄。我有幾個CDVViewController一起運行的原因。
這是應用程序如何添加父視圖控制器:
- (void)renderPlayer:(NSNotification*)notification {
SenchaViewController* newTopViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"SenchaView"];
NSDictionary *player = notification.object;
// Set active player
if(player != nil && [player valueForKey:@"playerID"] != @""){
// Attach Player Dictionary to Sencha View
newTopViewController.player = player;
// Send it to the top
CGRect frame = self.slidingViewController.topViewController.view.frame;
self.slidingViewController.topViewController = newTopViewController;
self.slidingViewController.topViewController.view.frame = frame;
}
這是怎麼擁有該CDVController父視圖控制器已經被刪除
_topViewController.view removeFromSuperview];
[_topViewController willMoveToParentViewController:nil];
[_topViewController removeFromParentViewController];
難道我失去了一些東西?我假設ARC會爲我解除這個問題