CALayer位置包含NaN:[nan -__]

时间:2016-11-12 09:03:43

标签: ios objective-c xcode slider calayer

***由于未捕获的异常'CALayerInvalidGeometry'终止应用,原因:'CALayer位置包含NaN:[nan 81]'// 81是运行时更改。

***首先抛出调用堆栈:

(
0   CoreFoundation                      0x000000011041a34b __exceptionPreprocess + 171
1   libobjc.A.dylib                     0x000000010f84021e objc_exception_throw + 48
2   CoreFoundation                      0x0000000110483265 +[NSException raise:format:] + 197
3   QuartzCore                          0x000000010c4842f2 _ZN2CA5Layer12set_positionERKNS_4Vec2IdEEb + 152
4   QuartzCore                          0x000000010c484467 -[CALayer setPosition:] + 44
5   UIKit                               0x000000010c7e18d2 -[UIView setCenter:] + 233
6   Hi2Buy                              0x000000010bf517e1 -[RangeSlider layoutSubviews] + 193
7   UIKit                               0x000000010c807344 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
8   QuartzCore                          0x000000010c48dcdc -[CALayer layoutSublayers] + 146
9   QuartzCore                          0x000000010c4817a0 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
10  QuartzCore                          0x000000010c48161e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
11  QuartzCore                          0x000000010c40f62c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
12  QuartzCore                          0x000000010c43c713 _ZN2CA11Transaction6commitEv + 475
13  QuartzCore                          0x000000010c43d083 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 113
14  CoreFoundation                      0x00000001103bee17 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
15  CoreFoundation                      0x00000001103bed87 __CFRunLoopDoObservers + 391
16  CoreFoundation                      0x00000001103a3b9e __CFRunLoopRun + 1198
17  CoreFoundation                      0x00000001103a3494 CFRunLoopRunSpecific + 420
18  GraphicsServices                    0x0000000112daba6f GSEventRunModal + 161
19  UIKit                               0x000000010c742f34 UIApplicationMain + 159
20  Hi2Buy                              0x000000010bfa3ddf main + 111
21  libdyld.dylib                       0x0000000111d7068d start + 1
22  ???                                 0x0000000000000001 0x0 + 1
)

libc++abi.dylib: terminating with uncaught exception of type NSException
  

我的代码:

RangeSlider *slider=  [[RangeSlider alloc] initWithFrame:self.viewSlider.bounds];
[slider addTarget:self action:@selector(slidreDrag:) forControlEvents:UIControlEventValueChanged];           
[self.viewSlider addSubview:slider];

1 个答案:

答案 0 :(得分:2)

解决这个问题解决方案我:

RangeSlider *slider=  [[RangeSlider alloc] initWithFrame:self.viewSlider.bounds];
slider.minimumValue = [minValue floatValue]; 
slider.selectedMinimumValue = [minValue floatValue];
slider.maximumValue = [maxValue floatValue];
slider.selectedMaximumValue = [maxValue floatValue];
slider.minimumRange = 2;
[slider addTarget:self action:@selector(slidreDrag:) forControlEvents:UIControlEventValueChanged];           
[self.viewSlider addSubview:slider];
  

原因

you are doesn't set value of minimum, maximum that this value by default select NaN value this type error occur.

Please set value.