Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UICollectionView多单元格(UICollectionViewCell)在Objective-C中闪烁同步_Ios_Objective C_Swift_Uicollectionview_Uicollectionviewcell - Fatal编程技术网

Ios UICollectionView多单元格(UICollectionViewCell)在Objective-C中闪烁同步

Ios UICollectionView多单元格(UICollectionViewCell)在Objective-C中闪烁同步,ios,objective-c,swift,uicollectionview,uicollectionviewcell,Ios,Objective C,Swift,Uicollectionview,Uicollectionviewcell,我有一个类似于UICollectionViewCell的问题,我必须同时闪烁多个单元格。但是现在如果一个单元格闪烁,那么如果我同时选择另一个单元格,而不是最后一个项目,则停止闪烁,该项目开始闪烁。我想闪烁标签文本 有两个问题: 我想闪烁,如果我甚至向上或向下滚动,它不应该影响或更新单元格。它应该继续闪烁 多个单元格闪烁 请原谅,我已经花了很多时间,我不知道如何解决 现在审判: 我现在已经试过了: 它解决了我手机闪烁错误的问题。但现在多个细胞一起闪烁如何解决这个我不知道 cell.pricePla

我有一个类似于
UICollectionViewCell
的问题,我必须同时闪烁多个单元格。但是现在如果一个单元格闪烁,那么如果我同时选择另一个单元格,而不是最后一个项目,则停止闪烁,该项目开始闪烁。我想闪烁标签文本

有两个问题:

  • 我想闪烁,如果我甚至向上或向下滚动,它不应该影响或更新单元格。它应该继续闪烁
  • 多个单元格闪烁
  • 请原谅,我已经花了很多时间,我不知道如何解决

    现在审判: 我现在已经试过了:

    它解决了我手机闪烁错误的问题。但现在多个细胞一起闪烁如何解决这个我不知道

    cell.pricePlate.alpha = 0;
    [UIView animateWithDuration:1.0f delay:0.1f options:UIViewAnimationOptionCurveLinear animations:^{
        [UIView setAnimationRepeatCount:3.0];
        cell.pricePlate.alpha = 1;
        cell.pricePlate.textColor = RED;
    } completion:^(BOOL finished) {
        NSLog(@"cell12 -> %ld  %ld",(long)cell.tag, (long)indexPath.row);
        cell.pricePlate.alpha = 1;
        if(self.cellIdToBlink <= 0)
        {
            cell.pricePlate.textColor = BLACK;
        }
        else
        { 
            cell.pricePlate.textColor = GREEN;
        }
    }];
    
    问题是,如果我向下滚动,即使只闪烁一次,也会闪烁并更新错误的单元格。同时移除闪烁。我认为这是因为当执行选择器时,它无法找到正确的单元格。所以它是随机闪烁的

    int counter = 1;
    for (int i = 0; i<3 ; i++)
    {
        if(i == 2)
        {
            [self performSelector:@selector(animateColor1234:) withObject:color afterDelay:1.5*counter];
            ++counter;
        }
        else{
            [self performSelector:@selector(animateColor1234:) withObject:BLACK afterDelay:1.5*counter];
            ++counter;
        }
    }
    
    -(void) animateColor1234:(UIColor *)color {
    
        [UIView transitionWithView:_pricePlate duration:1 options: UIViewAnimationOptionTransitionCrossDissolve animations:^{
            _pricePlate.textColor = RED;
        }
        completion:^(BOOL finished){
            if (finished){
                [UIView transitionWithView:_pricePlate duration:1 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
                    _pricePlate.textColor = BLACK;
                }
                completion:^(BOOL done){
                    if (done){
                        // Do some program upkeep logic
                        _pricePlate.textColor = color;
                    }
                }];
            }
            else
            {
                _pricePlate.textColor = color;
            }
        }];
    
    int计数器=1;
    
    对于(int i=0;i如果我理解正确,如果您想在标签上制作动画,无限次使用: UIView.animate(持续时间:2.0,延迟:0,选项:[.repeat,.autoreverse],动画:{}

    确保在不需要时不调用collection视图上的reloadData方法


    还要检查集合视图上的UI操作是否在主线程上完成。

    这里是一种解决方法

    我假设您现在使用重用单元/项

    问题的根本原因是重用特性

    因此,您可以尝试不使用重用方式

    下面的代码在UITableView中使用,但我相信您可以很容易地修改它

    在cellForRowAtIndexPath中替换重复使用的单元格代码:

    cell = [tableView dequeueReusableCellWithIdentifier:@"YourCellIdentifier"];
    
    致:


    请提供任何帮助,我们将不胜感激…[UIView setAnimationRepeatCount:3.0];不,我希望最终时间而不是无限时间我使用的是同一个兄弟…检查cell.pricePlate.alpha=0;[UIView动画宽度持续时间:1.0f延迟:0.1f选项:UIView动画选项曲线动画:^{[UIView设置动画重复计数:3.0];问题是多个动画同步…如选择多个项目…brother我检查了它,可能是因为这是问题:确保在不必要时不调用collection视图上的reloadData方法现在告诉我一件事,如firebase在运行时调用时,我必须调用reload data,这就是原因我认为这是在做……我如何解决这两件对我来说都很重要的事情1)重新加载数据2)调用firebase 2)调用firebase应该是第一位的,但这取决于您是否有分页(例如,您一次只获取20项,然后在需要时获取下一个20项)或者一次全部调用。最后一个更简单,您可以在viewDidLoad 1)上调用它,只有在从firebase收到结果后,您才应该重新加载collectionView。您可以使用reloadItems(在:)要重新加载某些单元格,不是所有单元格,让我试试……你不认为这会很贵吗?是的,会很贵。但有两个原因,1.如果UI不是很复杂或超过100个单元格,我认为可以。2.你的单元格/项目需要闪烁或其他动画,如果使用重复使用功能,应该对停止/启动动画进行其他控制,那么它可能会e很贵。
    - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
        CustomCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CarCellID" forIndexPath:indexPath];
    
        if(thisItemToBlink) 
        {
    
            cell.pricePlate.alpha = 0;
            [UIView animateWithDuration:1.0f delay:0.1f options:UIViewAnimationOptionCurveLinear animations:^{
                [UIView setAnimationRepeatCount:3.0];
                cell.pricePlate.alpha = 1;
                cell.pricePlate.textColor = RED;
            } completion:^(BOOL finished) {
                NSLog(@"cell12 -> %ld  %ld",(long)cell.tag, (long)indexPath.row);
                cell.pricePlate.alpha = 1;
                if(self.cellIdToBlink <= 0)
                {
                    cell.pricePlate.textColor = BLACK;
                }
                else
                {
                    cell.pricePlate.textColor = GREEN;
                }
            }];
        }
    
    }
    else
    {
        //just change text as not selected item
    }
    
    return cell;
    }
    
    cell = [tableView dequeueReusableCellWithIdentifier:@"YourCellIdentifier"];
    
    NSArray *nibObjs = [[NSBundle mainBundle] loadNibNamed:@"YourCellNibName" owner:nil options:nil];
    if(nibObjs)
      cell = [nibObjs objectAtIndex:0];