【问题标题】:Updating UIProgressView's progress dynamically动态更新 UIProgressView 的进度
【发布时间】:2012-05-10 10:09:09
【问题描述】:

以下是更新我的进度视图的场景。 我的问题是我的最后一个进度条只会更新.....

  1. 触摸时视图控制器有按钮,开始从 ftp 服务器下载。 立即触摸时导航到另一个视图控制器,其中 uitableview 显示正在进行的不同下载。

  2. 我将 UIProgressView 动态放入 UITableViewCell 中。

  3. 我是这样实现的……

    -- // cellForRowAtIndexPath // 向单元格添加进度视图

    progressBar = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar];
    progressBar.hidden=NO;
    progressBar.tag=123+indexPath.row;
    progressBar.frame = CGRectMake(250,170,350,25);
    progressBar.progress=0.0f;
    
  4. 更新progressview的进度 在 cellForRowAtIndexPath 的末尾 像这样......

       [NSTimer scheduledTimerWithTimeInterval:0.001f target:self selector:@selector(refreshProgress) userInfo:nil repeats:YES];
    
  5. //刷新进度的实现......

        -(void)refreshProgress
        {
    
    UITableViewCell *cell=(UITableViewCell *)[tempArray objectAtIndex:1];
    NSString * int_index=[tempArray objectAtIndex:0];
    FTPManager *objFTPMgr = [[FTPManager alloc] init];
    int index1=[int_index intValue];
    UIProgressView *prgView=(UIProgressView *)[cell viewWithTag:index1];
    prgView.progress = [objFTPMgr putProgress];
    [objFTPMgr release];
    [prgView reloadInputViews];
        }
    

    如果有人有解决方案,请写信到这个帖子

Thnx in advnce 帕吉 123

【问题讨论】:

  • 请提供有关 tempArray 及其组成的更多信息

标签: uitableview ios-4.2 uiprogressview


【解决方案1】:

不知道你有多少progresviews,但是使用refresProgress方法,你只调用tempArray[1]的单元格的进度视图;

你必须继承一个 UITableViewCell,并在其中创建一个带有 refreshProgresbar 的方法。然后,您可以遍历当前单元格并进行刷新。

【讨论】:

  • 我有 progessview 的动态计数,并且 tempArray 以这种方式定义------ // 在 cellForRowAtIndex ........... ......... NSString *strIndex=[NSString stringWithFormat:@"%d", progressBar.tag]; tempArray=[[NSMutableArray alloc]init]; [tempArray addObject:strIndex]; [tempArray addObject:cell];
猜你喜欢
  • 2011-04-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多