【问题标题】:App crashes on iPhone7 only: Fatal Exception: CALayerInvalidGeometry CALayer position contains NaN: [nan nan]应用程序仅在 iPhone7 上崩溃:致命异常:CALayerInvalidGeometry CALayer 位置包含 NaN:[nan nan]
【发布时间】:2018-03-07 06:48:40
【问题描述】:

我的应用程序在 iPhone6 上运行良好,但是当我在 iPhone7 上测试它时,当我尝试将点调整到图像时它崩溃了。

致命异常:CALayerInvalidGeometry CALayer位置包含NaN:[nan nan]

- (void)adjustPointsToFaceModel {

FaceFeatures *features = self.faceFeaturesModel.features;

CGRect featurePointsBox = [self.view featuresBoundingBox];

[self.view.featurePointsMapping enumerateKeysAndObjectsUsingBlock:^(NSNumber* key, FeaturePointView* view, BOOL *stop) {
    FaceFeaturePoint feature = key.unsignedIntegerValue;
    CGPoint pointCenter = [self.view convertPointFromImage:[features coordinatePointForFeature:feature]];

    if (pointCenter.x < CGRectGetMinX(featurePointsBox)) {
        pointCenter.x = CGRectGetMinX(featurePointsBox);
    }
    if (pointCenter.y < CGRectGetMinY(featurePointsBox)) {
        pointCenter.y = CGRectGetMinY(featurePointsBox);
    }
    if (pointCenter.x > CGRectGetMaxX(featurePointsBox)) {
        pointCenter.x = CGRectGetMaxX(featurePointsBox);
    }
    if (pointCenter.y > CGRectGetMaxY(featurePointsBox)) {
        pointCenter.y = CGRectGetMaxY(featurePointsBox);
    }
    view.center = pointCenter;
}];

[self.view layoutIfNeeded];
}

XCode 说

最后一个异常回溯 (0)

[self.view.featurePointsMapping enumerateKeysAndObjectsUsingBlock:^(NSNumber* key, EMFeaturePointView* view, BOOL *stop) {

为此花费了数周时间。欢迎任何帮助!

【问题讨论】:

标签: ios objective-c xcode crash


【解决方案1】:

我建议您添加检查以确保 featurePointsBox 矩形不包含任何 NaN 值。

请参阅以下主题: how to check for NaN value in Objective-C (iphone sdk)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-06
    • 2012-07-17
    • 1970-01-01
    • 2019-05-11
    • 2011-06-19
    相关资源
    最近更新 更多