Uncaught exception: CALayer position enthält NaN, wenn die animation zu tun
Ich bin immer diese Fehler in meiner Anwendung, wenn ich auf einem iPad:
Uncaught exception: CALayer position enthält NaN
Der gleiche code funktioniert auf einem iPhone.
- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views
{
AnnotationView *aV;
for (aV in views) {
//Don't pin drop if annotation is user location
if ([aV.annotation isKindOfClass:[MKUserLocation class]]) {
continue;
}
//Check if current annotation is inside visible map rect, else go to next one
MKMapPoint point = MKMapPointForCoordinate(aV.annotation.coordinate);
if (!MKMapRectContainsPoint(mapViewResult.visibleMapRect, point)) {
continue;
}
CGRect endFrame = aV.frame;
//Move annotation out of view
//I checked here, CGRectEmpty returns true here
aV.frame = CGRectMake(aV.frame.origin.x, aV.frame.origin.y - self.view.frame.size.height, aV.frame.size.width, aV.frame.size.height);
//Animate drop
[UIView animateWithDuration:0.5 delay:0.04*[views indexOfObject:aV] options: UIViewAnimationOptionCurveLinear animations:^{
aV.frame = endFrame;
//Animate squash
}completion:^(BOOL finished){
if (finished) {
[UIView animateWithDuration:0.05 animations:^{
aV.transform = CGAffineTransformMakeScale(1.0, 0.8);
}completion:^(BOOL finished){
if (finished) {
[UIView animateWithDuration:0.1 animations:^{
aV.transform = CGAffineTransformIdentity;
}];
}
}];
}
}];
}
}
Bekomme ich zu wissen, dass, die Rahmen, die die Zuordnung enthält NaN
Wert, ich habe diesen mit CGRectEmpty
Funktion und Einstellung das Bild CGRectZero
aber es wird nicht funktionieren.
Ich habe diese arbeiten, die code von hier, https://stackoverflow.com/a/7045916/1603234
Backtrace /Debug Log
*** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [594.947 nan]'
*** First throw call stack:
(
0 CoreFoundation 0x048551e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x034ad8e5 objc_exception_throw + 44
2 CoreFoundation 0x04854fbb +[NSException raise:format:] + 139
3 QuartzCore 0x01a1be1a _ZN2CA5Layer12set_positionERKNS_4Vec2IdEEb + 190
4 QuartzCore 0x01a1bfd9 -[CALayer setPosition:] + 68
5 QuartzCore 0x01a1c6df -[CALayer setFrame:] + 799
6 UIKit 0x01fbbb4d -[UIView(Geometry) setFrame:] + 302
7 MyAppName 0x0026b025 -[ResultMapViewController mapView:didAddAnnotationViews:] + 2133
8 MapKit 0x01e0449b -[MKMapView annotationManager:didAddAnnotationRepresentations:] + 272
9 MapKit 0x01e3b53c -[MKAnnotationManager updateVisibleAnnotations] + 2052
10 Foundation 0x02ed6de7 __NSFireTimer + 97
11 CoreFoundation 0x04813ac6 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
12 CoreFoundation 0x048134ad __CFRunLoopDoTimer + 1181
13 CoreFoundation 0x047fb538 __CFRunLoopRun + 1816
14 CoreFoundation 0x047fa9d3 CFRunLoopRunSpecific + 467
15 CoreFoundation 0x047fa7eb CFRunLoopRunInMode + 123
16 GraphicsServices 0x03ccd5ee GSEventRunModal + 192
17 GraphicsServices 0x03ccd42b GSEventRun + 104
18 UIKit 0x01f60f9b UIApplicationMain + 1225
19 MyAppName 0x0001ba3d main + 141
20 MyAppName 0x000027e5 start + 53
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Fügen Sie eine Ausnahme Haltepunkt. Gehen Sie auf die "Breakpoint-Navigator", klicken Sie auf das "+" in der linken unteren, wählen Sie "Add Exception Breakpoint." Führen Sie die app, um den Haltepunkt. Wenn Sie auf die exception-breakpoint auf Debuggen, weiter ein paar mal und erhalten Sie einen backtrace und mehr Fehler info. Post thatand eine exakte Kopie der Xcode - /Debugger-Nachrichten.
Ich habe gesehen, Verhalten dieser Art mit sehr kleinen Zeitintervallen, oder sehr animation - Schritten- ich vermute, letztlich als Ergebnis einen Wert, der so klein ist, dass es normalisiert auf null und wird dann verwendet, in der division.
Ich habe gesehen, Verhalten dieser Art mit sehr kleinen Zeitintervallen, oder sehr animation - Schritten- ich vermute, letztlich als Ergebnis einen Wert, der so klein ist, dass es normalisiert auf null und wird dann verwendet, in der division.
InformationsquelleAutor Hemang | 2014-04-08
Du musst angemeldet sein, um einen Kommentar abzugeben.
OMG!!! Ich wusste nicht, ich konnte machen solche "dummen" Fehler.
Ja, der Satz in Frage Der gleiche code funktioniert auf einem iPhone. Ich wurde immer Fehler
CALayer position contains NaN
weil in meinem custom- (AnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id ) annotation
Methode, wo ich bin, BerechnungannotationView.Bild war leer, weil ich vergaß hinzuzufügen, das pin-image in iPad-Projekt. Es war im iPhone-code. Es war also geteilt durch Null (0) und verursachen einen Fehler.
Ich setzte Pause, und drucken Sie mit
NSLog
Holen zu wissen, dass,1.0 - (diffFromBottom * 1.0)/annotationView.image.size.height
den Wert dieser gedruckt wurde,-inf
. Dies verursachte die app zum Absturz.Grundsätzlich tritt dieser Fehler auf, wenn Sie führen eine division durch unendlich oder null werden, so dass, wenn Sie bekam solche Fehler Erster Blick in den code, wo Sie die Durchführung der division.
InformationsquelleAutor Hemang