iOS设置正在处理图像时的进度条值

时间:2011-09-02 11:16:23

标签: iphone ios user-interface quartz-graphics uiprogressview

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

问题是,在处理我的图像时,UI似乎已被完全锁定,并且该值仅在完成所有过程后更改(意味着它只是在不经过子步骤的情况下达到1.0),< / p>

你们有没有遇到过这个?

伪:

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。非常感谢您的反馈或经验。

谢谢你 晒。

1 个答案:

答案 0 :(得分:2)

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

查看[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];

}