Używam trzeciej biblioteki CocoaPods napisanej w Objective-C, aby zrobić zrzut ekranu z UITextView. Było OK dla iOS 8, ale po tym, jak zmienić składnię dla iOS 9 i Swift 2, zgłasza błąd:podwarstwa z nieskończoną pozycją [inf inf]
Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'sublayer with non-finite position [inf inf]'
Oto kod z biblioteki:
- (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;
}
Problemem jest to, ta linia:
[self.layer renderInContext:context];
Zdaję sobie sprawę, to dlatego, że staram się wziąć migawkę UIView które zawierają UIScrollView. Jeśli usunę podgląd subskrypcji UIScrollView, błąd zniknie.
Co to oznacza?
sublayer with non-finite position [inf inf]
Ktoś mający ten sam problem i jak go rozwiązałeś?
Nie mogłem w to uwierzyć, ale to naprawiło: D wygląda jak ktoś w jabłku użyty == trochę za często;) –