0

只有在我退出该方法UIImageView后,才会在我的 ViewController 的窗口上绘制以下内容。
-(void)playOn:(UIViewController*) currentViewController这是为什么?我怎样才能做到这一点,以便我可以在该方法执行从该方法内部绘制我的 ViewController ?

细胞画家.m

-(void)paintGoodCellonViewController:(UIViewController*)playingViewController
{
    int x = 32*(xAxis - 1);
    int y = 384 - (32* yAxis);

    UIImageView* myImageView = [[UIImageView alloc] initWithImage:goodCell];
    myImageView.frame = CGRectMake(x,y, 32, 32);
    [playingViewController.view addSubview:myImageView];
}

游戏.m

-(void)playOn:(UIViewController*) currentViewController
{    
    [currentPainter paintGoodCellonViewController:currentViewController];

    while(!self.stopButtonPressed)
    {
        // code...
    }
}

我的视图控制器.m

- (IBAction)enterButtonPressed:(UIButton *)sender
{
    [currentGame performSelectorInBackground:@selector(playOn:) withObject:self];
}

- (IBAction)giveUpButtonPressed:(UIButton *)sender
{
    currentGame.stopButtonPressed = YES;

}
4

1 回答 1

1

使用此代码强制UIView重绘:

[myView setNeedsDisplay];
于 2012-08-23T15:37:47.153 回答