Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/102.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何解决由于未捕获异常“CALayerInvalidGeometry”而终止应用程序的问题,原因:“CALayer边界包含NaN:[NaN 1365;50 320]?_Ios_Objective C - Fatal编程技术网

Ios 如何解决由于未捕获异常“CALayerInvalidGeometry”而终止应用程序的问题,原因:“CALayer边界包含NaN:[NaN 1365;50 320]?

Ios 如何解决由于未捕获异常“CALayerInvalidGeometry”而终止应用程序的问题,原因:“CALayer边界包含NaN:[NaN 1365;50 320]?,ios,objective-c,Ios,Objective C,我有一个应用程序正在崩溃,并显示以下消息: 2014-08-03 03:00:50.245 ios_psy_msu[3500:60b] *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer bounds contains NaN: [nan 1365; 50 320]' *** First throw call stack: ( 0 CoreFoundation

我有一个应用程序正在崩溃,并显示以下消息:

2014-08-03 03:00:50.245 ios_psy_msu[3500:60b] *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer bounds contains NaN: [nan 1365; 50 320]'
*** First throw call stack:
(
    0   CoreFoundation                      0x0241f1e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x0219e8e5 objc_exception_throw + 44
    2   CoreFoundation                      0x0241efbb +[NSException raise:format:] + 139
    3   QuartzCore                          0x01035a3b _ZN2CA5Layer10set_boundsERKNS_4RectEb + 267
    4   QuartzCore                          0x01035d06 -[CALayer setBounds:] + 135
    5   UIKit                               0x012e2781 -[UIView(Geometry) setBounds:] + 358
    6   UIKit                               0x012ff627 -[UIScrollView setBounds:] + 1036
    7   UIKit                               0x01373f5f -[UITableView setBounds:] + 260
    8   UIKit                               0x012ffb9b -[UIScrollView setContentOffset:] + 690
    9   UIKit                               0x01374aad -[UITableView setContentOffset:] + 342
    10  UIKit                               0x012fa2c3 -[UIScrollViewScrollAnimation setProgress:] + 463
    11  UIKit                               0x0138bcb4 -[UIAnimator(Static) _advanceAnimationsOfType:withTimestamp:] + 287
    12  UIKit                               0x0138b846 -[UIAnimator(Static) _LCDHeartbeatCallback:] + 67
    13  QuartzCore                          0x01067d66 _ZN2CA7Display15DisplayLinkItem8dispatchEv + 48
    14  QuartzCore                          0x01067c22 _ZN2CA7Display11DisplayLink14dispatch_itemsEyyy + 310
    15  QuartzCore                          0x01068147 _ZN2CA7Display16TimerDisplayLink8callbackEP16__CFRunLoopTimerPv + 123
    16  CoreFoundation                      0x023ddac6 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
    17  CoreFoundation                      0x023dd4ad __CFRunLoopDoTimer + 1181
    18  CoreFoundation                      0x023c5538 __CFRunLoopRun + 1816
    19  CoreFoundation                      0x023c49d3 CFRunLoopRunSpecific + 467
    20  CoreFoundation                      0x023c47eb CFRunLoopRunInMode + 123
    21  GraphicsServices                    0x03ae05ee GSEventRunModal + 192
    22  GraphicsServices                    0x03ae042b GSEventRun + 104
    23  UIKit                               0x01284f9b UIApplicationMain + 1225
    24  ios_psy_msu                         0x0005f83d main + 141
    25  libdyld.dylib                       0x03779701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
在我的应用程序中,我使用CustomTableViewCell。然后我尝试使用UITableView手机,我的应用程序运行得很好。我认为这次事故的原因是在海关牢房里。这是我的CustomTableViewCell

    #import "LessonCell.h"


static const CGFloat kCellHeight = 100.0f;
static const NSInteger kCellMargin = 8;
static const NSInteger kClockHeight = 20;
static const NSInteger kHeaderHeight = 30;
static const NSInteger kIconWidth = 40;

@implementation LessonCell




- (void)initialization
{
    // progress view example.
    self.backgroundShadowView = [[BaseProgressView alloc] initWithFrame:CGRectMake(kCellMargin + kIconWidth, kCellMargin + kClockHeight,
                                                                                   ViewWidth(self) - 2 * kCellMargin - kIconWidth,
                                                                                   kCellHeight - kCellMargin)];
    [self.backgroundShadowView.layer setCornerRadius:2.0f];
    [self.backgroundShadowView.layer setMasksToBounds:YES];
    self.backgroundShadowView.backgroundColor = AppShadowColor;
    [self.contentView addSubview:self.backgroundShadowView];

    self.backgroundContentView = [[UIView alloc] initWithFrame:CGRectMake(kCellMargin + kIconWidth, kCellMargin + + kClockHeight,
                                                                          ViewWidth(self) - 2 * kCellMargin - kIconWidth,
                                                                          kCellHeight - kCellMargin - 2)];
    [self.backgroundContentView.layer setCornerRadius:2.0f];
    [self.backgroundContentView.layer setMasksToBounds:YES];
    [self.backgroundContentView.layer setBorderWidth:1.0f];
    [self.backgroundContentView.layer setBorderColor:AppSeparatorColor.CGColor];
    [self.backgroundContentView setBackgroundColor:AppCloudsColor];
    [self.contentView addSubview:self.backgroundContentView];

    FAKFoundationIcons *clockIcon = [FAKFoundationIcons clockIconWithSize:18];
    UIImageView* clockView = [[UIImageView alloc] initWithImage:
                              [[clockIcon imageWithSize:CGSizeMake(18, 18)] imageTintedWithColor:AppSubTextColor]];
    [clockView setCenter:CGPointMake(ViewX(self.backgroundContentView) + 9, kCellMargin + kClockHeight / 2)];
    [self.contentView addSubview:clockView];

    self.clockLabel = [[CustomLabel alloc] initWithFrame:CGRectMake(ViewX(clockView) + ViewWidth(clockView) + 5,
                                                                   ViewY(clockView),
                                                                   ViewWidth(self) - ViewX(clockView) - ViewWidth(clockView) - 10,
                                                                    10)];
    [self.clockLabel setFont:FontAppRegular(12)];
    [self.clockLabel setTextAlignment:NSTextAlignmentLeft];
    [self.clockLabel setTextColor:AppSubTextColor];
    [self.contentView addSubview:self.clockLabel];

    self.headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ViewWidth(self.backgroundContentView), kHeaderHeight)];
    [self.headerView setBackgroundColor:AppGrayColor];
    [self.backgroundContentView addSubview:self.headerView];

    FAKIonIcons *arrowIcon = [FAKIonIcons arrowLeftBIconWithSize:18];
    self.arrow = [[UIImageView alloc] initWithImage:[[arrowIcon imageWithSize:CGSizeMake(18, 18)] imageTintedWithColor:AppGrayColor]];
    [self.arrow setCenter:CGPointMake(kCellMargin + kIconWidth - 2, kCellMargin + kClockHeight + ViewHeight(self.headerView) / 2)];
    [self.arrow setBackgroundColor:[UIColor clearColor]];
    [self.contentView addSubview:self.arrow];

    self.typeView = [[LessonTypeView alloc] initWithFrame:CGRectMake(0, kClockHeight, kIconWidth - 6, kIconWidth - 6)];
    [self.contentView addSubview:self.typeView];

    self.titleLabel = [[CustomLabel alloc] initWithFrame:CGRectMake(10, 0, ViewWidth(self) - 10 - kIconWidth, 18)];
    [self.titleLabel setTextAlignment:NSTextAlignmentLeft];
    [self.titleLabel setBackgroundColor:[UIColor clearColor]];
    [self.titleLabel setTextColor:AppCloudsColor];
    [self.titleLabel setFont:FontAppRegular(14)];
    [self.headerView addSubview:self.titleLabel];

    self.teachedView = [[LessonParametrView alloc] initWithFrame:CGRectMake(0, kHeaderHeight, ViewWidth(self.backgroundContentView), 10)];
    [self.backgroundContentView addSubview:self.teachedView];

    self.placeView = [[LessonParametrView alloc] initWithFrame:CGRectMake(0, kHeaderHeight, ViewWidth(self.backgroundContentView), 10)];
    [self.backgroundContentView addSubview:self.placeView];

    [self setBackgroundColor:[UIColor clearColor]];
}

- (id)init
{
    self = [super init];
    if (self) {
        [self initialization];
    }

    return self;
}

- (CGFloat)configureWithModel:(LessonModel*)object
{
    [self.titleLabel setText:object.name];
    [self.headerView setFrame:CGRectMake(0, 0, ViewWidth(self.backgroundContentView), ViewHeight(self.titleLabel) + 10)];
    NSCalendar *calendar = [NSCalendar currentCalendar];
    [calendar setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"MSK"]];
    NSDateComponents *startComponents = [calendar components:(NSHourCalendarUnit | NSMinuteCalendarUnit) fromDate:object.start_time];
    NSString* startCompMin = (long)[startComponents minute] < 10 ? [NSString stringWithFormat:@"%d%ld", 0,
                                                                    (long)[startComponents minute]]
                                                                 : [NSString stringWithFormat:@"%ld", (long)[startComponents minute]];
    NSDateComponents *finishComponents = [calendar components:(NSHourCalendarUnit | NSMinuteCalendarUnit) fromDate:object.finish_time];
    NSString* finishCompMin = (long)[finishComponents minute] < 10 ? [NSString stringWithFormat:@"%d%ld", 0,
                                                                   (long)[finishComponents minute]]
                                                                : [NSString stringWithFormat:@"%ld", (long)[finishComponents minute]];

    NSString* timeStr = [NSString stringWithFormat:@"%ld:%@ - %ld:%@",
                         (long)[startComponents hour],
                         startCompMin,
                         (long)[finishComponents hour],
                         finishCompMin];

    [self.clockLabel setText:timeStr];

    [self.titleLabel setCenter:CGPointMake(ViewWidth(self.headerView) / 2 + 10, ViewHeight(self.headerView) / 2)];

    [self.arrow setCenter:CGPointMake(kCellMargin + kIconWidth - 2, kCellMargin + kClockHeight + ViewHeight(self.headerView) / 2)];
    [self.typeView setCenter:CGPointMake(3 + kIconWidth / 2, kCellMargin + kClockHeight + ViewHeight(self.headerView) / 2)];
    [self.typeView configureWithType:object.lesson_type];

    FAKIonIcons *personIcon = [FAKIonIcons personIconWithSize:26];
    [self.teachedView setFrame:CGRectMake(0, ViewHeight(self.headerView),
                                          ViewWidth(self.backgroundContentView), 10)];
    [self.teachedView configureWithTitle:@"Teacher"
                             description:object.teacher
                                 andIcon:[[personIcon imageWithSize:CGSizeMake(26, 26)] imageTintedWithColor:AppShadowColor]];

    FAKIonIcons *locationIcon = [FAKIonIcons locationIconWithSize:26];
    [self.placeView setFrame:CGRectMake(ViewX(self.placeView), ViewHeight(self.headerView) + ViewHeight(self.teachedView),
                                          ViewWidth(self.backgroundContentView), 10)];
    [self.placeView configureWithTitle:@"Place"
                             description:object.place
                                 andIcon:[[locationIcon imageWithSize:CGSizeMake(26, 26)] imageTintedWithColor:AppShadowColor]];

    [self.backgroundContentView setFrame:CGRectMake(kCellMargin + kIconWidth, kCellMargin + kClockHeight,
                                                   ViewWidth(self) - 2 * kCellMargin - kIconWidth,
                                                    ViewHeight(self.headerView) + ViewHeight(self.teachedView) + ViewHeight(self.placeView))];

    [self.backgroundShadowView setFrame:CGRectMake(kCellMargin + kIconWidth, kCellMargin + kClockHeight,
                                                   ViewWidth(self) - 2 * kCellMargin - kIconWidth,
                                                   ViewHeight(self.headerView) + ViewHeight(self.teachedView) + ViewHeight(self.placeView) + 2)];

    CGFloat height = ViewHeight(self.backgroundContentView) + kCellMargin * 4;

    return height;
}

+ (CGFloat)computeContentHeight:(LessonModel*)object
{
    return [[[LessonCell alloc] init] configureWithModel:object];
}

问题似乎不在您的手机中。问题是您试图以某种方式设置无效的内容偏移量。堆栈跟踪显示此UITableView setContentOffset:。在视图控制器中查找调整内容偏移的位置。我在控制器中不使用内容偏移方法: