Я много смотрел на это, но я могу только представить webView и таблицы, относящиеся к этой проблеме. Mine совершенно другой, похоже, с тем же исключением:
CALayerInvalidGeometry ', reason:' CALayer bounds содержит NaN: [0 0; nan nan]
В основном то, что у меня есть, - это представление, которое уменьшает и масштабирует изображения. Недавно я решил изменить свой код, используя CGAffineTransformScale в анимации UIView, вместо того, чтобы масштабировать все до отметки каждый раз, когда таймер тикает. Это использует меньшую вычислительную мощность.
Но независимо от того, в каком порядке у меня есть фотографии, он всегда падает после 19-го. Кажется, что это не проблема с массивом координат позиционирования, на который он ссылается, поскольку он имеет длину всего 6 и петли после того, как он достигает своей длины. Поэтому по какой-то причине с тех пор, как я реализовал этот код анимации, это дает мне эту ошибку. Кто-нибудь знает, почему?
Здесь часть, которую я изменил с момента ее срыва:
-(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;}
ИЗМЕНИТЬ
Вот как я получил код выше, чтобы работать без проблемы с использованием CGAffineTransformIdentity.
-(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;}