I have placed a UIProgressView
in UITableViewCell
. There are two issues I am facing :
1. UITableView
scroll is getting hindered.
2. UIProgressView
setProgress is called each time (obviously) which sets its progress each time it appears.
It is understandable that issue 1 occurs because of issue 2. To test this, I commented the UIProgressView
in UITableViewCell
. The scroll is so fast then.
This is the code for UIProgressView
:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
SWTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[SWTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.backgroundColor = [UIColor clearColor];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryType = UITableViewCellAccessoryNone;
if ([cell respondsToSelector:@selector(layoutMargins)]) {
cell.layoutMargins = UIEdgeInsetsZero;
cell.preservesSuperviewLayoutMargins = false;
}
}
else
{
NSArray *arr = [cell.contentView subviews];
for(int i=0; i<[arr count]; i++)
{
UIView *view = [arr objectAtIndex:i];
[view removeFromSuperview];
}
}
CustomerArticleDetail *customerArticleDetails = [arrDetails objectAtIndex:indexPath.row];
...
...
UIProgressView *progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];
[progressView setProgressTintColor:[UIColor colorWithRed:31.0/255 green:177.0/255 blue:137.0/255 alpha:1.0]];
[[progressView layer]setCornerRadius:5.0f];
[[progressView layer]setBorderWidth:2.0f];
[[progressView layer]setMasksToBounds:TRUE];
progressView.clipsToBounds = YES;
[[progressView layer]setFrame:CGRectMake(50, 93, self.view.frame.size.width - 55, 8)];[[progressView layer]setBorderColor:[UIColor whiteColor].CGColor];
progressView.trackTintColor = [UIColor colorWithRed:233.0/255.0 green:233.0/255.0 blue:233.0/255.0 alpha:1.0];
[progressView setProgress: ([customerArticleDetails.Logged_Hours floatValue]/[customerArticleDetails.Planned_Hours floatValue]) animated:YES];
[cell.contentView addSubview:progressView];
...
...
return cell;
}