Objective c 为什么不是';我的UIImageView对象是否实时绘制?
以下Objective c 为什么不是';我的UIImageView对象是否实时绘制?,objective-c,ios,uiviewcontroller,uiimageview,drawing,Objective C,Ios,Uiviewcontroller,Uiimageview,Drawing,以下UIImageView仅在我退出后才会在我的ViewController窗口上绘制 -(void)playOn:(UIViewController*)currentViewController方法。为什么呢?我怎样才能在该方法执行时从该方法内部绘制ViewController 画师 -(void)paintGoodCellonViewController:(UIViewController*)playingViewController { int x = 32*(xAxis - 1)
UIImageView
仅在我退出后才会在我的ViewController窗口上绘制-(void)playOn:(UIViewController*)currentViewController
方法。为什么呢?我怎样才能在该方法执行时从该方法内部绘制ViewController
画师
-(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];
}
游戏
-(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;
}
使用此代码强制
UIView
重画:
[myView setNeedsDisplay];
你的意思是我调用
[myImageView setNeedsDisplay]代码>紧跟在[playingViewController.view添加子视图:myImageView]之后代码>在上述设置中,或在该设置之前?将视图添加到UI后调用它。另一方面,你可能想要阅读。