2012-05-10 51 views
0

以下是更新我的progressview的場景。 我的問題是我最後的進度僅獲取更新.....動態更新UIProgressView的進度

  1. 的視圖 - 控制是有按鈕時開始接觸從FTP服務器下載。 立即觸摸導航到另一個視圖控制器,其中uitableview顯示正在進行不同的下載。

  2. 我把UIProgressView動態地放入UITableViewCell中。

  3. 我以這種方式實現它....

    - //的cellForRowAtIndexPath //添加progressview在的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的進步像這樣......

    [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在advnce 佩琪123

+0

請提供一些關於tempArray的信息,它由 –

回答

0

我不不知道你有多少個progresviews,但用refresProgress方法,你只能調用tempArray [1]單元格的進度視圖;

你必須繼承一個UITableViewCell,並在那裏用refreshProgresbar創建一個方法。然後,您可以遍歷當前的單元格並進行刷新。

+0

即時動態計數progessview和tempArray是這樣定義的------ //在cellForRowAtIndex ........., ................. NSString * strIndex = [NSString stringWithFormat:@「%d」,progressBar.tag]; \t tempArray = [[NSMutableArray alloc] init]; \t [tempArray addObject:strIndex]; \t [tempArray addObject:cell]; – user968597