首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Iphone >

关于线程的有关问题?

2012-12-26 
关于线程的问题???高手请进!!!!!!创建了一个线程,专门来读取视频源,当读到视频数据已经,保存为一个UIImage

关于线程的问题???高手请进!!!!!!
创建了一个线程,专门来读取视频源,当读到视频数据已经,保存为一个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 first please try "change waitUntilDone to TRUE", if it's not OK. try #2
2 please check the run loop mode of main thread .
[其他解释]
完整代码贴出来,包括声明部分
[其他解释]
没有人知道吗??自己先顶一下
[其他解释]

引用:
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 .

谢谢,我试试看
[其他解释]
虽然不是很懂,但先mark一下
[其他解释]
引用:
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 .

第一条是不行,测试过了,第二条能否说具体一点跟main thread有关系吗?
[其他解释]
奇怪的是当得到图片了以后,保存到Array中的以后必须要用控件UIImageView显示出来,Array中的图片才会是不一样的,如果得到图片了没有用控件显示,那么Array中的图片全部都是最后的一张,不知道何解
[其他解释]
没有人知道了吗?自己先顶一下
[其他解释]
该回复于2012-10-17 15:26:41被版主删除

热点排行