objective-c - 实时,为什么我的UIImageView对象不被绘制?

  显示原文与译文双语对照的内容
0 0

这个问题已经有了如下答案:

下面的UIImageView 仅在我退出后才在viewcontroller窗口上绘制
-(void)playOn:(UIViewController*) currentViewController 我怎么才能画出这个方法,在这个方法中,这个方法正在执行 executing?

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;
}
时间:原作者:1个回答

0 0

使用这里代码强制 UIView 重绘:

[myView setNeedsDisplay];
原作者:
...