2010-04-06 100 views
2

我已将UIImageView绘制在我的笔尖文件中,并且它已连接到imageView iboutlet。我可以加载单独的图片,这些图片会很好地显示出来,但是当涉及到像动画一样分别绘制许多图像时,图像不会显示。我有drawImage()函数,它采用NSData对象(图像数据)并将其绘制到屏幕(imageView)。iPhone:UIImageView不显示图像

主函数得到了循环,它尽可能快地循环300次,每次调用drawImage函数并将不同的图像数据传递给它。有时当我执行此代码时,最后一张来自该“动画”的图片显示出来,有时甚至完全没有。也许我需要为imageView安排足够的时间,以便可以显示图像?

希望有人有一些线索。提前致谢!

+0

你的确切目的是什么......你想一个接一个地动画......? – 2010-04-06 11:35:55

+0

是的,它应该尽可能快地逐一绘制它们。从0到300. – George 2010-04-06 11:40:59

回答

0

尝试像

// create the view that will execute our animation 
    UIImageView* ImageView = [[UIImageView alloc] initWithFrame:self.view.frame]; 

    // load all the frames of our animation 
    ImageView.animationImages = [NSArray arrayWithObjects: 
           [UIImage imageNamed:@"1.png"], 
           [UIImage imageNamed:@"2.png"], 
           [UIImage imageNamed:@"3.png"], 
          nil]; 

    // all frames will execute in 1.75 seconds 
    ImageView.animationDuration = 1.75; 
    // repeat the annimation forever 
    ImageView.animationRepeatCount = 0; 
    // start animating 
    [ImageView startAnimating]; 
    // add the animation view to the main window 
    [self.view addSubview:ImageView]; 
0

只是几分钟前,打这场6小时左右,我设法得到它的工作像我想以后。

这是一个神奇的行做到了:

[self.imageView performSelectorInBackground:@selector(setImage:) 
           withObject:imageData]; 

感谢您的帮助! :)

+2

所以,你不应该把它标记为回答吗? – Dad 2010-08-29 19:05:25