2017-05-18 18 views
0

私はUITableViewにいくつかのカスタムUITableViewCellを設定しました。そのうちの1つでは、データの割合を表すUIProgressViewがあります。 しかし、私は(のは50%にしましょう)進捗状況を設定すると、プログレスバーが50%で表示され、それが100%に達するまで、自分自身を更新...カスタムUITableViewCellのUIProgressView自体の更新

ここで私は、データを更新するために使用するコード:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    NSString *CellIdentifier = [menuItems objectAtIndex:indexPath.row]; 
    cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 


    if ([appliedTheme hasPrefix:@"DarkMode"]) { 

     self.tableView.backgroundColor = [UIColor colorWithRed:0.20 green:0.20 blue:0.20 alpha:1.0]; 
     cell.backgroundColor = [UIColor colorWithRed:0.20 green:0.20 blue:0.20 alpha:1.0]; 
     cell.cardView.backgroundColor = [UIColor colorWithRed:0.30 green:0.30 blue:0.30 alpha:1.0]; 


     cell.storageIntroLabel.textColor = [UIColor whiteColor]; 
     cell.storageInfoTitle.textColor = [UIColor whiteColor]; 
     cell.deviceStorageTitle.textColor = [UIColor whiteColor]; 

    }else { 

     self.tableView.backgroundColor = [UIColor colorWithRed:0.92 green:0.92 blue:0.92 alpha:1.0]; 
     cell.backgroundColor = [UIColor colorWithRed:0.92 green:0.92 blue:0.92 alpha:1.0]; 
     cell.cardView.backgroundColor = [UIColor whiteColor]; 


     cell.storageIntroLabel.textColor = [UIColor blackColor]; 
     cell.storageInfoTitle.textColor = [UIColor blackColor]; 
     cell.deviceStorageTitle.textColor = [UIColor blackColor]; 

    } 


    if ([CellIdentifier isEqualToString:@"storageIntro"]) { 

     cell.storageIntroImageView.image = [UIImage imageNamed:storageIntroIconToShow]; 
     cell.storageIntroLabel.adjustsFontSizeToFitWidth = YES; 
     cell.storageIntroLabel.numberOfLines = 0; 
     [cell.storageIntroLabel sizeToFit]; 
     cell.storageIntroLabel.text = NSLocalizedString(@"Here you can find informations about your storage and how FileStore is using your memory by types of files", nil); 

    }else if ([CellIdentifier isEqualToString:@"storageInfo"]){ 

     cell.storageInfoTitle.text = NSLocalizedString(@"Storage Informations", nil); 
     cell.deviceStorageTitle.adjustsFontSizeToFitWidth = YES; 
     cell.deviceStorageTitle.text = NSLocalizedString(@"Device Storage", nil); 
     cell.totalDeviceSpaceLabel.adjustsFontSizeToFitWidth = YES; 
     cell.totalDeviceSpaceLabel.text = NSLocalizedString(@"Total space :", nil); 
     cell.finalTotalDeviceSpaceLabel.text = totalDeviceSpaceString; 
     cell.freeDeviceSpaceLabel.adjustsFontSizeToFitWidth = YES; 
     cell.freeDeviceSpaceLabel.text = NSLocalizedString(@"Free space :", nil); 
     cell.finalFreeDeviceSpaceLabel.text = totalDeviceFreeSpaceString; 
     dispatch_async(dispatch_get_main_queue(), ^{ 

      [cell.deviceStorageProgressView setProgress:50 animated:YES]; 

     }); 

    }else { 



    } 


    return cell; 

} 

ブールanimated:YESを使用しなくても、設定した割合からプログレスバーが自動的に更新されます。 それは私に何の意味もありません!他のセルのデリゲートメソッドでUIProgressView設定を行う必要がありますか?

ご協力いただきありがとうございます。

答えて

1

UIProgressView documentation

によれば現在の進行状況が1.0タスクの完了を示し包括0.0と1.0の間の浮動小数点値によって表されます。デフォルト値は0.0です。 0.0より小さい値と1.0より大きい値は、これらの制限値に固定されます。

あなたはあなたが50%の進捗をしたい場合0.5としての価値を与える必要があり、基本的に上限値1に変換されますにそれを設定しています。

+0

ああ...私には恥がある!それはあなたが過度に疲れているときにやる間違いです^^ '私は今夜テストし、あなたの答えを検証します、ありがとう;) – Synny

関連する問題