web-dev-qa-db-fra.com

CalayerInvalidiestomies ', Raison:' Calayer limites contient Nan: [0 0; Nan Nan] Crash en vue

J'ai beaucoup ressemblé à cela, mais je ne peux que sembler obtenir webview et tables relatifs à cette question. Le mien totalement différent semble avec la même exception de crash:

CalayerInvalidiestomies ', Raison:' Calayer limites contient Nan: [0 0; Nan Nan]

Fondamentalement, ce que j'ai ici est une vue qui fausse et des images d'échelle. J'ai récemment décidé de changer mon code à l'aide de CgaffinetransformScale dans une animation UIView au lieu de mettre à l'échelle des choses à chaque fois une tickets de minuterie. Cela utilise une manière moins de pouvoir de traitement.

Mais peu importe quel ordre j'ai les images, il se bloque toujours après le 19ème. Il ne semble pas être un problème avec le réseau de coordonnées de positionnement qu'il fait référence, car il n'a que 6 longueurs et boucles après avoir atteint sa longueur. Donc, pour une raison quelconque depuis que j'ai mis en œuvre ce code d'animation, cela me donne cet accident. Quelqu'un sache pourquoi?

Voici la partie que j'ai changée depuis que cela a commencé à planter:

-(void) onTimer{

if(scaleTimer_A==5){

    imageView_A.image = [UIImage imageNamed:[attractList_A objectAtIndex:imageIndex_A]];

    imageView_A.frame = CGRectMake(300, 200, 3.86, 3.86);

    imageView_A.center = CGPointMake(attractLocs_x_A[attractLocs_A_index], attractLocs_y_A[attractLocs_A_index]);



    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:2];
    imageView_A.alpha = 1;
    imageView_A.transform = CGAffineTransformScale(imageView_A.transform, 100, 100);
    [UIView commitAnimations]; 
}

if(scaleTimer_A==10){

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:.75];
    imageView_A.alpha = 0;
    imageView_A.transform = CGAffineTransformScale(imageView_A.transform, 1.2, 1.2);
    [UIView commitAnimations]; 

    scaleTimer_A=0;

    imageIndex_A+=1;

    if(imageIndex_A==imageIndex_A_size){
        imageIndex_A=0;
    }

    attractLocs_A_index+=1;

    if(attractLocs_A_index==attractLocs_A_SIZE){
        NSLog(@"Back to zero A");
        attractLocs_A_index=0;
    }
    NSLog(@"Image A =%@", [attractList_A objectAtIndex:imageIndex_A]);
}

scaleTimer_A+=1;}

ÉDITER :

Voici comment j'ai obtenu le code ci-dessus pour travailler sans le problème de crash à l'aide de CGAFFINETRANSELIDITY.

-(void) onTimer{

if(scaleTimer_A==5){

    imageView_A.image = [UIImage imageNamed:[attractList_A objectAtIndex:imageIndex_A]];

    imageView_A.transform = CGAffineTransformIdentity;

    imageView_A.center = CGPointMake(attractLocs_x_A[attractLocs_A_index], attractLocs_y_A[attractLocs_A_index]);



    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:2];
    imageView_A.alpha = 1;
    imageView_A.transform = CGAffineTransformScale(CGAffineTransformIdentity, 100, 100);
    [UIView commitAnimations]; 
}

if(scaleTimer_A==10){

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:.75];
    imageView_A.alpha = 0;
    imageView_A.transform = CGAffineTransformScale(CGAffineTransformIdentity, 120, 120);
    [UIView commitAnimations]; 

    scaleTimer_A=0;

    imageIndex_A+=1;

    if(imageIndex_A==imageIndex_A_size){
        imageIndex_A=0;
    }

    attractLocs_A_index+=1;

    if(attractLocs_A_index==attractLocs_A_SIZE){
        NSLog(@"Back to zero A");
        attractLocs_A_index=0;
    }
    NSLog(@"Image A =%@", [attractList_A objectAtIndex:imageIndex_A]);
}

scaleTimer_A+=1;}
22
Chewie The Chorkie

Selon la trace de la pile, le problème est ici

imageView_A.frame = CGRectMake(300, 200, 3.86, 3.86);

Essayez de définir l'imageview_a.transform vers l'identité. Une autre solution (et je pense mieux) utiliserait l'Uiscrollview pour la mise à l'échelle (elle pourrait également être animée).

Edit: essayez ceci

    imageView_A.image = [UIImage imageNamed:[attractList_A objectAtIndex:imageIndex_A]];

    imageView_A.frame = CGRectMake(300, 200, 3.86, 3.86);

    imageView_A.center = CGPointMake(attractLocs_x_A[attractLocs_A_index], attractLocs_y_A[attractLocs_A_index]);



    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:2];
    imageView_A.alpha = 1;
    imageView_A.frame = CGRectMake(300, 200, 386.0f, 386.0f);
    [UIView commitAnimations]; 
10
Max