Answer the question
In order to leave comments, you need to log in
How to resolve Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer bounds contains NaN: [nan 1365; 50 320]?
Error output in console:
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
#import "LessonCell.h"
#pragma mark - Инициализация
/**
* Начальная инициализация объекта при создании
*/
- (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];
self.headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ViewWidth(self.backgroundContentView), kHeaderHeight)];
[self.headerView setBackgroundColor:AppGrayColor];
[self.backgroundContentView addSubview:self.headerView];
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;
}
#pragma mark - Настройка с помощью модели
/**
* Настройка ячейки данными модели
*/
- (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 *locationIcon = [FAKIonIcons locationIconWithSize:26];
[self.placeView setFrame:CGRectMake(ViewX(self.placeView), ViewHeight(self.headerView) + ViewHeight(self.teachedView),
ViewWidth(self.backgroundContentView), 10)];
[self.placeView configureWithTitle:@"Аудитория"
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)];
// Рассчет высоты ячейки и установка ProgressView
CGFloat height = ViewHeight(self.backgroundContentView) + kCellMargin * 4;
return height;
}
#pragma mark - Публичные методы
/**
* Вычисление высоты ячейки, достаточной для вмещения всего содержимого
*/
+ (CGFloat)computeContentHeight:(LessonModel*)object
{
return [[[LessonCell alloc] init] configureWithModel:object];
}
@end
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question