创建了一个线程,专门来读取视频源,当读到视频数据已经,保存为一个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的图片永远都是最后的一张图片请教各位这个是什么原因呢?
然后将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的图片永远都是最后的一张图片请教各位这个是什么原因呢?
解决方案 »
- 关于ios自动切换颜色模板的问题
- 项目以前用的是coco2d-x 2.0.2开发的,现在我要替换成2.1.0版本的-X
- iphone開發 怎麼點擊一個按鈕 程序自動就退出了?怎麼回事
- property的3个属性。retain/copy/assign
- 请问如何搭建phonegap开发iphone的环境
- 求助!发布IPA后在ITUNES中没有图标的解决为法~
- 【微信登陆】的乱码问题!
- 通过UIAerltView对话框的按钮,回收键盘
- 新人初学ios,对于for循环遍历和forin循环遍历的使用场景很混乱,希望有人能指点迷津。
- iOS开发遇难题求大佬帮忙
- cocos2dx 怎么引用mach.h
- 想问一下,腾讯开放平台申请的应用里面的key不是即时生效的吗?
2 please check the run loop mode of main thread .