在处理图像时,iOS设置进度栏值 [英] iOS setting Progress bar value while images are being processed

查看:72
本文介绍了在处理图像时,iOS设置进度栏值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序使用Quartz处理几个图像,我想拥有一个UIProgressView,它在每次操作后都会改变。 (例如0.0 0.2 0.4 0.6 0.8 0.8 1.0)

I have an app processing a couple of images using Quartz, and i wanted to have a UIProgressView that changes after each actions. (e.g. 0.0 0.2 0.4 0.6 0.8 1.0)

问题是,似乎在处理我的图像时,UI已完全锁定,并且只有在所有这个过程完成了(这意味着它不经过子步骤就达到1.0),

The problem is, it seems while my image is being processed the UI is completely locked, and the value only changes after all of the process is done (meaning it just gets to 1.0 without going through the sub-steps),

您有没有遇到过这个?

Did any of you ever encounter this ?

伪:

for(uint i=0;i<5;i++){
    // Execute some Quartz based action here, such as CGContextDrawTiledImage etc...
    myProgress.progress = (i+1) * 0.2;          
}

实际上,而不是每次操作后更改进度条,它只会更改一次最后是1.0。

So actually instead of the progress bar changing after each action, it only changes once at the end to 1.0. Would appreciate your feedback or experience or this.

谢谢您

Shai。

Thank you
Shai.

推荐答案

您需要在单独的线程中更新资产或进度条,以便两者可以并行更新。

You'll need to update either your assets or your progress bar in a separate thread so that the two can update in parallel.

看看 [NSThread detachNewThreadSelector:selector toTarget:target withObject:object];

取得进展成员变量

 [NSThread detachNewThreadSelector:@selector(updateFilterProgress) toTarget:self withObject:nil];

 prgLoader.progress = x;


- (void) updateFilterProgress{

    NSAutoreleasePool *pool = [NSAutoreleasePool new];

    while ([prgLoader.progress floatValue] < 1.0f)    //Keep this thread alive till done loading. You might want to include a way to escape (a BOOL flag)
    {
        GTMLoggerInfo(@"Updating progress to %f", [progress floatValue]);
        prgLoader.progress = [progress floatValue];
    }
    [pool release];

}

这篇关于在处理图像时,iOS设置进度栏值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆