UIProgressview委派更新未显示进度条值更新

时间:2013-06-17 06:51:09

标签: iphone ios5 uiprogressview

我在iCarousel类的反射视图中有一个UIProgressView对象

当我尝试更新ProgressView时不更新

使用委托方法

更新进度视图

当下载完成图像时,我会像这样调用委托方法

if([viewdelegate respondsToSelector:@selector(DidFinishprocess:tag:)])
{
     [viewdelegate DidFinishprocess:value tag:bookid];
}

另一方面更新我实施此方法的进度条

-(void)DidFinishprocess:(float)progress tag:(int)bookid
{
NSArray *arr = carousel.visibleItemViews; //carousel.visibleItemViews;
    for (UIView *vi in arr)
    {
        if ([vi isKindOfClass:[ReflectionView class]])
        {
             if (vi.tag == bookid)
             {

                 for (UIProgressView *v in vi.subviews)
                 {
                      if ([v isKindOfClass:[UIProgressView class]])
                      {
                            progressView = (UIProgressView*)v;
                            [progressView setProgress:progress animated:YES];
                            NSLog(@"%f",progress);

                            //Here i m getting the new value of progress bar but the progress view doesn't how the update                                                                       

                            progressView=nil;
                            break;
                      }
                  }
               }

            }
        }
 } 

1 个答案:

答案 0 :(得分:0)

- (void)DidFinishprocess:(float)progress tag:(int)bookid
{ 
    //code  ...

    [progressView setProgress:progress animated:YES];

    //code  ...
}

指定的progress变量的值必须为float

UIProgressBar值的范围从0.0(0%)到1.0(100%)

您的值应以0.1,0.2,0.3等的分数递增。 例如:

[progressView setProgress:bytesReceived/bytesTotal animated:YES];

如果你得到progress的值,范围从0到100(例如10,11,12 ......)那么你必须把它变成一个分数,除以100:

[progressView setProgress:progress/100 animated:YES];