Sto utilizzando una terza libreria CocoaPods scritta in Objective-C per acquisire uno screenshot di UITextView. E 'stato OK per iOS 8, ma dopo che ho cambiato la sintassi per iOS 9 e Swift 2, si genera un errore:sottolivello con posizione non finita [inf inf]
Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'sublayer with non-finite position [inf inf]'
ecco il codice dalla libreria:
- (UIImage *)screenshotForCroppingRect:(CGRect)croppingRect
{
UIGraphicsBeginImageContextWithOptions(croppingRect.size, NO, [UIScreen mainScreen].scale);
// Create a graphics context and translate it the view we want to crop so
// that even in grabbing (0,0), that origin point now represents the actual
// cropping origin desired:
CGContextRef context = UIGraphicsGetCurrentContext();
if (context == NULL) return nil;
NSLog(@"hiii :%f" , croppingRect.size.width);
CGContextTranslateCTM(context, -croppingRect.origin.x, -croppingRect.origin.y);
[self layoutIfNeeded];
[self.layer renderInContext:context];
UIImage *screenshotImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return screenshotImage;
}
Il problema è questa linea:
[self.layer renderInContext:context];
mi rendo conto che questo è perché sto cercando di scattare un'istantanea del UIView che contengono un UIScrollView. Se rimuovo la sottoview UIScrollView, l'errore è scomparso.
Che cosa significa?
sublayer with non-finite position [inf inf]
Chiunque abbia lo stesso problema e come lo ha risolto?
Non riuscivo a crederci ma l'ho risolto: D sembra che qualcuno della mela abbia usato == un po 'troppo spesso;) –