Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"photoCell"];
  2.  
  3. PhotoCell *photoCell = (PhotoCell *)cell;
  4. if(indexPath.row==self.resultArray.count-1 && self.onEdit){
  5. self.onEdit = NO;
  6. [photoCell.resultImageV setHidden:YES];
  7. float rand = 5 + arc4random_uniform(26);
  8. photoCell.time=0.0;
  9. photoCell.totalTime = rand/50;
  10. NSLog(@"loading---%@---time>>%f", indexPath, rand);
  11. NSTimer *timer = [NSTimer timerWithTimeInterval:0.5f target:self selector:@selector(updateTimer:) userInfo:photoCell repeats:YES];
  12. [[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
  13. UIProgressView *progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar];
  14. progressView.frame = CGRectMake(0, photoCell.resultImageV.frame.size.height/2, photoCell.resultImageV.frame.size.width, photoCell.resultImageV.frame.size.height);
  15. [progressView setTag:11];
  16. [photoCell.contentView addSubview:progressView];
  17. }
  18. UIImage *img = (UIImage *)[self.resultArray objectAtIndex:indexPath.row];
  19. photoCell.resultImageV.image = img;
  20. return cell;
  21.  
  22. PhotoCell *cell = timer.userInfo; //index of tableview for current timer
  23. if(cell.time >= cell.totalTime)
  24. {
  25. UIProgressView *prg = [cell viewWithTag:11];
  26. [prg removeFromSuperview];
  27. [cell.resultImageV setHidden:NO];
  28. [timer invalidate];
  29. }
  30. else
  31. {
  32. cell.time += 0.01;
  33. float progress = cell.time/cell.totalTime;
  34. UIProgressView *prg = [cell viewWithTag:11];
  35. prg.progress = progress;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement