gpt4 book ai didi

ios - UIProgressView 在自定义 UITableViewCell 中自行更新

转载 作者:行者123 更新时间:2023-11-29 00:21:44 25 4
gpt4 key购买 nike

我有一个 UITableView,其中填充了几个自定义 UITableViewCell。在其中一个中,我有一个 UIProgressView,它将代表数据的百分比。但是,当我设置进度(假设为 50%)时,进度条显示为 50% 并自行更新,直到达到 100%...

这是我用来更新数据的代码:

- (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;

}

即使我不使用 bool animated:YES,进度条也会随着时间的推移根据我设置的百分比自行更新...这对我来说没有任何意义!我是否必须将 UIProgressView 设置放入另一个单元格的委托(delegate)方法中?

在此先感谢您的帮助!

最佳答案

根据 UIProgressView documentation

The current progress is represented by a floating-point value between 0.0 and 1.0, inclusive, where 1.0 indicates the completion of the task. The default value is 0.0. Values less than 0.0 and greater than 1.0 are pinned to those limits.

您将其设置为 50,这基本上会转换为上限值 1。如果您想要 50% 的进度,您需要将值设置为 0.5

关于ios - UIProgressView 在自定义 UITableViewCell 中自行更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44046499/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com