以下UIImageView
は、メソッドを終了した後にのみ、ViewController のウィンドウに描画されます
-(void)playOn:(UIViewController*) currentViewController
。何故ですか?メソッドの実行中にそのメソッド内から ViewController を描画できるようにするにはどうすればよいですか?
CellPainter.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];
}
Game.m
-(void)playOn:(UIViewController*) currentViewController
{
[currentPainter paintGoodCellonViewController:currentViewController];
while(!self.stopButtonPressed)
{
// code...
}
}
MyViewController.m
- (IBAction)enterButtonPressed:(UIButton *)sender
{
[currentGame performSelectorInBackground:@selector(playOn:) withObject:self];
}
- (IBAction)giveUpButtonPressed:(UIButton *)sender
{
currentGame.stopButtonPressed = YES;
}