Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/105.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 为什么不是';我的UIImageView对象是否实时绘制?_Objective C_Ios_Uiviewcontroller_Uiimageview_Drawing - Fatal编程技术网

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后调用它。另一方面,你可能想要阅读。