0

AppDelegate から ViewController クラスにメソッドを呼び出そうとしていますが、メソッドに入りますが、問題は何も表示されないことです。探していましたが、答えが見つかりません。誰かが私を助けることができますか?ありがとう

これはコードです:

AppDelegate.m

- (void)applicationWillEnterForeground:(UIApplication *)application
{

    if (mainDelegate.isflagON=TRUE)
    {

        ViewController *vc=[ViewController new];
        [vc pause];

    }

}

ViewController.m

- (void)viewDidLoad
{

    [super viewDidLoad];
    AppDelegate *mainDelegate = [[UIApplication sharedApplication] delegate];
    if (mainDelegate.isflagON==false)
    {
        mainDelegate.isflagON=true;
        CGSize viewSize = self.view.bounds.size;
        // Add this line

        GameScene *scene = [[GameScene alloc] initWithSize:viewSize];
        scene.scaleMode = SKSceneScaleModeAspectFill;
        self.scene = scene;

        // Configure the view.
        skView = (SKView *)self.view;
        skView.showsFPS = YES;
        skView.showsNodeCount = YES;


        // Present the scene.
        [skView presentScene:scene];

    }else
    {
        [self doPause];
    }
}

-(void) imprime
{
    [self doPause];

}

- (void)doPause {

    CGRect myImageRect = CGRectMake(0.0f, 0.0f, 200.0f, 200.0f);
    backImageView = [[UIImageView alloc] initWithFrame:myImageRect];
    [backImageView setImage:[UIImage imageNamed:@"dialogBox.png"]];
    [self.view addSubview:backImageView];
    [self.view sendSubviewToBack:backImageView];

    //set the position of the button

    buttonContinuar = [UIButton buttonWithType:UIButtonTypeCustom];

    [buttonContinuar setBackgroundImage:[UIImage imageNamed:@"dialogButton.png"]
                               forState:UIControlStateNormal];
    buttonContinuar.frame = CGRectMake(40.0f, 50.0f, 120, 35);
    [buttonContinuar addTarget:self action:@selector(buttonWasClicked:) forControlEvents:UIControlEventTouchUpInside];
    [buttonContinuar setTitle:@"Continuar" forState:UIControlStateNormal];
    //add the button to the view
    [self.view addSubview:buttonContinuar];

    buttonMapa = [UIButton buttonWithType:UIButtonTypeCustom];
    //[button setTitle:@"Continuar" forState:UIControlStateNormal];

    [buttonMapa setBackgroundImage:[UIImage imageNamed:@"dialogButton.png"]
                          forState:UIControlStateNormal];
    buttonMapa.frame = CGRectMake(40.0f, 85.0f, 120, 35);
    [buttonMapa addTarget:self action:@selector(buttonMapaClicked:) forControlEvents:UIControlEventTouchUpInside];
    [buttonMapa setTitle:@"Mapa" forState:UIControlStateNormal];
    //add the button to the view
    [self.view addSubview:buttonMapa];

    buttonMenu = [UIButton buttonWithType:UIButtonTypeCustom];
    //[button setTitle:@"Continuar" forState:UIControlStateNormal];

    [buttonMenu setBackgroundImage:[UIImage imageNamed:@"dialogButton.png"]
                          forState:UIControlStateNormal];
    buttonMenu.frame = CGRectMake(40.0f, 120.0f, 120, 35);
    [buttonMenu addTarget:self action:@selector(buttonMenuClicked:) forControlEvents:UIControlEventTouchUpInside];
    [buttonMenu setTitle:@"Menu" forState:UIControlStateNormal];
    //add the button to the view
    [self.view addSubview:buttonMenu];

}
4

1 に答える 1

0

これを試すことができます

- (void)applicationWillEnterForeground:(UIApplication *)application
{

    if (mainDelegate.isflagON=TRUE)
    {

        ViewController *vc=[[ViewController alloc]init];
        [vc pause];

    }

}
于 2013-08-06T04:35:20.310 に答える