创建了一个线程,专门来读取视频源,当读到视频数据已经,保存为一个UIImage 
然后将UIImage放到NSMutableArray *saveImage;数组中
线程中的代码如下
self.currentImage = [self imageFromAVPicture:picture width:self.outputWidth height:self.outputHeight]; //转化为图片
//保存到saveImage
[self performSelectorOnMainThread:@selector(saveVideoImage:) withObject:self.currentImage waitUntilDone:NO];saveVideoImage函数在主线程中如下
- (void)saveVideoImage:(UIImage *)img
{
    [self.saveImage addObject:img];
}当视频源的数据读取完整以后,我查看保存在saveImage中的图片
发现所有的图片都是最后的一张,太奇怪了
当我在[self performSelectorOnMainThread:@selector(saveVideoImage:) withObject:self.currentImage waitUntilDone:NO];后面加上一个控件来显示动态读取的图片[self performSelectorOnMainThread:@selector(showTableVideo) withObject:nil waitUntilDone:NO];
showTableVideo函数在主线程在中如下
- (void)showTableVideo
{
    self.showVideo.image = self.currentImage;//showVideo是一个UIImageView控件
}
调用了showTableVideo显示图片以后saveImage中的图片每一张都是不一样的
但是如果不调用主线程中的showTableVideo,saveImage的图片永远都是最后的一张图片请教各位这个是什么原因呢?

解决方案 »

  1.   

    1 first please try "change waitUntilDone to TRUE", if it's not OK. try #2
    2 please check the run loop mode of main thread .
      

  2.   

    第一条是不行,测试过了,第二条能否说具体一点跟main thread有关系吗?
      

  3.   

    奇怪的是当得到图片了以后,保存到Array中的以后必须要用控件UIImageView显示出来,Array中的图片才会是不一样的,如果得到图片了没有用控件显示,那么Array中的图片全部都是最后的一张,不知道何解