1

I have added CABasicAnimation on a layer which is added as sublayer to a custom view.Custom view is then added to collection view cell content view as subview. I want to show indefinite progress like bar moving from left to right until download completes(please refer the attachments). Everything is fine except, once download is completed,For removing the custom view with layer animation, i cannot access that view using the tag. The compiler crashes and throws 'could not load any Objective-C class information. This will significantly reduce the quality of type information available'

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{

    NSMutableDictionary *attachDetail = [self getManagedObjectForIndexPath:indexPath];


    ZCRMMailAttachmentCollectionViewCell *cell = (ZCRMMailAttachmentCollectionViewCell*)[collectionView dequeueReusableCellWithReuseIdentifier:@"cellId" forIndexPath:indexPath];

    [self setVisibilityOfRemoveButtonInCell:cell inObj:attachDetail];
    [self setVisibilityOfSizeInCell:cell inObj:attachDetail];
    cell.attachDetails = attachDetail;

    [self addLoadingViewIfNotDownloaded:cell managedObject:attachDetail];

    [cell redraw];

    return cell;

}

-(void)addLoadingViewIfNotDownloaded:(ZCRMMailAttachmentCollectionViewCell*)cell managedObject:(NSDictionary*)attachDict
{
   NSNumber *progress = attachDict[MAIL_ATTACH_DOWNLOAD_PROGRESS];
   if(!ZV_IsEmpty(progress))
   {
      if (isinf([progress floatValue]))
      {
        [cell addLinearInfiniteProgress];
      }
      else
      {
        [cell removeLinearProgress];
       }
   } 
}

-(void)addLinearInfiniteProgress
{
    UIView* view = [zTvContentView viewWithTag:1234];

    if(!view)
    {
        UIView *progressView = [UIView new];
        progressView.tag = 1234;
        progressView.layer.masksToBounds = YES;


        [zTvContentView addSubview:progressView];
        [progressView setBottom:-1];
        [progressView alignTo:VTLayoutAlignLeft|VTLayoutAlignRight];
        [progressView setHeight:2];


            //ProgressLayer

            CGRect frame = self.contentView.bounds;

            CALayer * indeterminateLayer = [CALayer layer];
            indeterminateLayer.delegate = self;
            indeterminateLayer.name = @"progresslayer";
            indeterminateLayer.frame = CGRectMake(0, 0, 0.4*CGRectGetWidth(frame), 3);
            indeterminateLayer.backgroundColor = [CurTheme() themeActionItemColor].CGColor;
            indeterminateLayer.opacity = 1;
            [progressView.layer addSublayer:indeterminateLayer];

            CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];
            animation.duration = 1;
            animation.repeatCount = HUGE_VALF;
            animation.removedOnCompletion = YES;
            animation.fromValue = [NSValue valueWithCGPoint:CGPointMake( CGRectGetMinX(frame) - indeterminateLayer.frame.size.width + OFFSET, 0)];
            animation.toValue = [NSValue valueWithCGPoint:CGPointMake(CGRectGetMaxX(frame) + indeterminateLayer.frame.size.width - OFFSET, 0)];


            [indeterminateLayer addAnimation:animation forKey:@"position"];

    }
}

(void)removeLinearInfiniteProgress
{
    UIView* progressView = [zTvContentView viewWithTag:1234];

    if(progressView)
    {
        if ([progressView superview])
        {
            [progressView removeFromSuperview];
        }
    }
}

Any help would be appreciated.

enter image description here enter image description here

Kalai_Human
  • 135
  • 7

0 Answers0