create a new NSNotificationCenter inside your UIViewController class inside viewDidAppear function
1).
this would remove Scene from view not skview from your viewController its skivew that maintain cache for high performance so you need to remove skview from viewController add few lines to your code for that
this would remove skview from your parent viewController
1).
-(void)viewDidAppear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(disMissViewController) name:@"disMissViewController" object:nil];
}
2.)
create selector
-(void)disMissViewController{
//in case of story board
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
mainView= [storyboard instantiateViewControllerWithIdentifier:@"main" ];
//in case of code
mainView=[[UIViewController alloc] init];
[self presentViewController:newviewController animated:YES completion:^{
}];
//remove Notification
[[NSNotificationCenter defaultCenter] removeObserver:self
name:@"disMissViewController"
object:nil];
}
3) calling NSNotificationCenter from your skscene
[[NSNotificationCenter defaultCenter] postNotificationName:@"disMissViewController" object:self];
thats it work done remember
one thing skview maintain cache so removing Scene from view does not remove it all
such as
-(void)willMoveFromView:(SKView *)view
{
[self removeAllChildren];
[self removeAllActions];
[self removeFromParent];
[self.view presentScene:nil];
}
this would remove skview from your parent viewController
-(void)viewDidDisappear:(BOOL)animated {
if( self.skView ) {
NSLog(@"%s - removing skView",__PRETTY_FUNCTION__);
[self.skView removeFromSuperview];
self.skView = nil;
}
}
for more information click the below link
https://developer.apple.com/library/ios/qa/qa1889/_index.html
https://developer.apple.com/library/ios/qa/qa1889/_index.html
Comments
Post a Comment