I got the code in second (SKView) class:

 -(void)backToMenu
 {
     GamePlay1 *controller = [[GamePlay1 alloc]init];
     [controller end];
 }

In my first class i have this method that dismiss view controller:

 -(void)end
 {
      NSLog(@"I am here");

      [self dismissViewControllerAnimated:YES completion:nil];
 }

It works just fine and i got the message "I am here".. But it won't trigger the dismiss line? Is maybe problem that i am creating new instance of class GamePlay1 instead calling the one that already exist? I am lost here don't know what to do.

有帮助吗?

解决方案

Yes you understand the actual problem

Try to create

//In appdegate .h

GamePlay1 *controller;

//In appdegate .m

controller = [[GamePlay1 alloc]init];

in app delegate file so that you will get access of controller object. Then it will trigger the dismiss

To access it use

AppDelegate  *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
[appDelegate.controller end];
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top