进入方法但不显示任何内容

时间:2013-08-05 22:54:07

标签: methods call viewcontroller appdelegate

我试图将一个方法调用到ViewController类表单AppDelegate,它输入到方法但问题是没有显示任何东西,我一直在找,但我找不到答案。有人可以帮助我吗?感谢

这是代码:

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];

}

1 个答案:

答案 0 :(得分:0)

你可以试试这个

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

    if (mainDelegate.isflagON=TRUE)
    {

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

    }

}