Ios 演示modalViewController的是dealloc';叫它的那个
我在整合灰色成熟广告时遇到了一些问题(有文档记录,但并不重要)。解决我的问题的一种方法就是这样展示我的游戏视图Ios 演示modalViewController的是dealloc';叫它的那个,ios,xcode,cocoa-touch,uiviewcontroller,modalviewcontroller,Ios,Xcode,Cocoa Touch,Uiviewcontroller,Modalviewcontroller,我在整合灰色成熟广告时遇到了一些问题(有文档记录,但并不重要)。解决我的问题的一种方法就是这样展示我的游戏视图 iSlideAppDelegate *appDelegate = (iSlideAppDelegate *)[[UIApplication sharedApplication] delegate]; UIStoryboard *storyboard = self.storyboard; Game3ViewController *gameV
iSlideAppDelegate *appDelegate = (iSlideAppDelegate *)[[UIApplication sharedApplication] delegate];
UIStoryboard *storyboard = self.storyboard;
Game3ViewController *gameView = (Game3ViewController *)[storyboard instantiateViewControllerWithIdentifier:@"mainGameController"];
[appDelegate.window addSubview:gameView.view];
FullScreenSelfAdViewController *adView = [[FullScreenSelfAdViewController alloc] initWithNibName:@"FullScreenSelfAdViewController" bundle:nil];
[adView setDismissDelegate:self];
[self presentModalViewController:adView animated:YES];
这基本上只是将我的游戏视图添加到当前视图控制器的顶部
现在从这个视图中,我想显示另一个类似这样的模态视图
iSlideAppDelegate *appDelegate = (iSlideAppDelegate *)[[UIApplication sharedApplication] delegate];
UIStoryboard *storyboard = self.storyboard;
Game3ViewController *gameView = (Game3ViewController *)[storyboard instantiateViewControllerWithIdentifier:@"mainGameController"];
[appDelegate.window addSubview:gameView.view];
FullScreenSelfAdViewController *adView = [[FullScreenSelfAdViewController alloc] initWithNibName:@"FullScreenSelfAdViewController" bundle:nil];
[adView setDismissDelegate:self];
[self presentModalViewController:adView animated:YES];
问题是,当显示此视图时,我的gameView取消分配。也就是说,当我打电话取消AdView时,它是dealloc,但会留在屏幕上,因为根本的gameView已经不存在了
有没有更好的方式来称呼这些观点?(我不能以模式视图的形式调用gameView)。
还是一种防止gameView取消分配的方法?如果我不得不猜测的话,您没有一个强大的变量来保留被取消分配的类。创建该类的人都应该有一个强大的ivar。当我试图创建一个对象并在不保留它的情况下使用它时,我遇到了完全相同的问题。请注意,对于UIAlerts,当您调用[alert show]时,系统会保留它,这会让人认为您可以使用其他视图控制器(您不能!)
祝你好运。谢谢。创建一个强变量是可行的。有趣的是,你竟然忽视了你大部分时间都在做的事情。哈,问我是怎么知道答案的:-)我在猜几个小时,想弄明白为什么有些东西不会保留下来。英雄联盟