2017-11-16 1 views
0
'이 아닌 경우

Objective-C에서 Core-Plot 1.6을 사용하는 이전 앱에서 작업하고 있습니다. 나는 왼쪽과 오른쪽 축 Y.에 나는 마우스 오른쪽 Y 액세스에 레이블을 추가하기 위해 노력하고있어,하지만 나는이 같은 axisConstraint 속성을 설정하는 경우에만 충돌 :Core-Plot의 축 설정이 오류로 인해 충돌 함 'orthogonalRange가'

rightY.axisConstraints = [CPTConstraints constraintWithUpperOffset:0]; 

이 전체 코드가입니다 내가 뭘하려고하는지.

CPTXYAxis *rightY = [[CPTXYAxis alloc] init]; 
// Configure the right y-axis 
rightY.labelingPolicy = CPTAxisLabelingPolicyNone; 
rightY.title = NSLocalizedStringFromTable(@"Time (Sec)", @"Scores", @"Time in seconds label for scores"); 
rightY.titleTextStyle = axisTitleStyle; 
rightY.titleOffset = 23.0f; 
rightY.axisLineStyle = axisLineStyle; 
rightY.tickDirection = CPTSignPositive; 
rightY.labelingPolicy = CPTAxisLabelingPolicyNone; 
rightY.labelOffset = 4.0f; 
rightY.majorTickLineStyle = axisLineStyle; 
rightY.majorTickLength = -5.0f; 
rightY.minorTickLength = -2.5f; 
rightY.axisConstraints = [CPTConstraints constraintWithUpperOffset:0]; 

NSInteger rightMajorIncrement = 1; 
NSInteger rightMinorIncrement = 1; 


CGFloat rightYMax = 12; // should determine dynamically based on max price 
NSMutableSet *rightYLabels = [NSMutableSet set]; 
NSMutableSet *rightYMajorLocations = [NSMutableSet set]; 
NSMutableSet *rightYMinorLocations = [NSMutableSet set]; 
for (NSInteger j = rightMinorIncrement; j <= rightYMax; j += rightMinorIncrement) { 
    NSUInteger mod = j % rightMajorIncrement; 
    if (mod == 0) { 
     CPTAxisLabel *label = [[CPTAxisLabel alloc] initWithText:[NSNumberFormatter localizedStringFromNumber:@(13 - j) numberStyle:NSNumberFormatterNoStyle] textStyle:rightY.labelTextStyle]; 
     NSDecimal rightLocation = CPTDecimalFromInteger(j); 
     label.tickLocation = rightLocation; 
     label.offset = 2; 
     if (label) { 
      [rightYLabels addObject:label]; 
     } 
     [rightYMajorLocations addObject:[NSDecimalNumber decimalNumberWithDecimal:rightLocation]]; 
    } else { 
     [rightYMinorLocations addObject:[NSDecimalNumber decimalNumberWithDecimal:CPTDecimalFromInteger(j)]]; 
    } 
} 
rightY.axisLabels = rightYLabels; 

axisLabels에 rightYLabels을 추가하면 위의 행에서 충돌합니다.

편집 :

충돌 정보 :

Exception Type: EXC_CRASH (SIGABRT) 
Exception Codes: 0x0000000000000000, 0x0000000000000000 
Exception Note: EXC_CORPSE_NOTIFY 
Triggered by Thread: 0 

Application Specific Information: 
abort() called 

Filtered syslog: 
None found 

Last Exception Backtrace: 
(0x182f67d38 0x18247c528 0x182f67c0c 0x1838f6c24 0x1026561d4 0x102656634 0x1025b7918 0x1025b9934 0x102576d30 0x102574510 0x1025744b4 0x102571a48 0x102570cc8 0x18c377bfc 0x18c3777d4 0x18c4fce28 0x18c41ee04 0x18c41ea34 0x18c41e95c 0x18c375000 0x186f450b4 0x186f49194 0x186eb7f24 0x186ede340 0x186edf180 0x182f0f8b8 0x182f0d270 0x182f0d82c 0x182e2e2d8 0x184cbff84 0x18c3db880 0x102519218 0x18295256c) 

Thread 0 name: Dispatch queue: com.apple.main-thread 
Thread 0 Crashed: 
0 libsystem_kernel.dylib   0x0000000182a81348 0x182a60000 + 136008 
1 libsystem_pthread.dylib   0x0000000182b95354 0x182b92000 + 13140 
2 libsystem_c.dylib    0x00000001829f0fd8 0x18298e000 + 405464 
3 libc++abi.dylib     0x0000000182454068 0x182452000 + 8296 
4 libc++abi.dylib     0x0000000182454210 0x182452000 + 8720 
5 libobjc.A.dylib     0x000000018247c810 0x182474000 + 34832 
6 libc++abi.dylib     0x000000018246c54c 0x182452000 + 107852 
7 libc++abi.dylib     0x000000018246c158 0x182452000 + 106840 
8 libobjc.A.dylib     0x000000018247c6e8 0x182474000 + 34536 
9 CoreFoundation     0x0000000182e2e344 0x182e26000 + 33604 
10 GraphicsServices    0x0000000184cbff84 0x184cb5000 + 44932 
11 UIKit       0x000000018c3db880 0x18c368000 + 473216 
12 Counting      0x0000000102519218 0x102514000 + 21016 
13 libdyld.dylib     0x000000018295256c 0x182951000 + 5484 

Thread 1: 
0 libsystem_kernel.dylib   0x0000000182a81dbc 0x182a60000 + 138684 
1 libsystem_pthread.dylib   0x0000000182b92fb0 0x182b92000 + 4016 
2 libsystem_pthread.dylib   0x0000000182b92c30 0x182b92000 + 3120 

Thread 2: 
0 libsystem_kernel.dylib   0x0000000182a81dbc 0x182a60000 + 138684 
1 libsystem_pthread.dylib   0x0000000182b92fb0 0x182b92000 + 4016 
2 libsystem_pthread.dylib   0x0000000182b92c30 0x182b92000 + 3120 

Thread 3: 
0 libsystem_kernel.dylib   0x0000000182a81dbc 0x182a60000 + 138684 
1 libsystem_pthread.dylib   0x0000000182b93144 0x182b92000 + 4420 
2 libsystem_pthread.dylib   0x0000000182b92c30 0x182b92000 + 3120 

Thread 4 name: com.apple.uikit.eventfetch-thread 
Thread 4: 
0 libsystem_kernel.dylib   0x0000000182a60bc4 0x182a60000 + 3012 
1 libsystem_kernel.dylib   0x0000000182a60a3c 0x182a60000 + 2620 
2 CoreFoundation     0x0000000182f0fce4 0x182e26000 + 957668 
3 CoreFoundation     0x0000000182f0d8b0 0x182e26000 + 948400 
4 CoreFoundation     0x0000000182e2e2d8 0x182e26000 + 33496 
5 Foundation      0x00000001838566e4 0x18384a000 + 50916 
6 Foundation      0x0000000183875afc 0x18384a000 + 178940 
7 UIKit       0x000000018cf2702c 0x18c368000 + 12316716 
8 Foundation      0x0000000183957860 0x18384a000 + 1103968 
9 libsystem_pthread.dylib   0x0000000182b9432c 0x182b92000 + 9004 
10 libsystem_pthread.dylib   0x0000000182b941f8 0x182b92000 + 8696 
11 libsystem_pthread.dylib   0x0000000182b92c38 0x182b92000 + 3128 

Thread 5 name: AVAudioSession Notify Thread 
Thread 5: 
0 libsystem_kernel.dylib   0x0000000182a60bc4 0x182a60000 + 3012 
1 libsystem_kernel.dylib   0x0000000182a60a3c 0x182a60000 + 2620 
2 CoreFoundation     0x0000000182f0fce4 0x182e26000 + 957668 
3 CoreFoundation     0x0000000182f0d8b0 0x182e26000 + 948400 
4 CoreFoundation     0x0000000182e2e2d8 0x182e26000 + 33496 
5 AVFAudio      0x00000001886f7774 0x188673000 + 542580 
6 AVFAudio      0x0000000188722018 0x188673000 + 716824 
7 libsystem_pthread.dylib   0x0000000182b9432c 0x182b92000 + 9004 
8 libsystem_pthread.dylib   0x0000000182b941f8 0x182b92000 + 8696 
9 libsystem_pthread.dylib   0x0000000182b92c38 0x182b92000 + 3128 

Thread 6 name: com.apple.coreaudio.AQClient 
Thread 6: 
0 libsystem_kernel.dylib   0x0000000182a60bc4 0x182a60000 + 3012 
1 libsystem_kernel.dylib   0x0000000182a60a3c 0x182a60000 + 2620 
2 CoreFoundation     0x0000000182f0fce4 0x182e26000 + 957668 
3 CoreFoundation     0x0000000182f0d8b0 0x182e26000 + 948400 
4 CoreFoundation     0x0000000182e2e2d8 0x182e26000 + 33496 
5 AudioToolbox     0x0000000186aea99c 0x1868df000 + 2144668 
6 AudioToolbox     0x0000000186d22630 0x1868df000 + 4470320 
7 libsystem_pthread.dylib   0x0000000182b9432c 0x182b92000 + 9004 
8 libsystem_pthread.dylib   0x0000000182b941f8 0x182b92000 + 8696 
9 libsystem_pthread.dylib   0x0000000182b92c38 0x182b92000 + 3128 

Thread 7 name: com.apple.NSURLConnectionLoader 
Thread 7: 
0 libsystem_kernel.dylib   0x0000000182a60bc4 0x182a60000 + 3012 
1 libsystem_kernel.dylib   0x0000000182a60a3c 0x182a60000 + 2620 
2 CoreFoundation     0x0000000182f0fce4 0x182e26000 + 957668 
3 CoreFoundation     0x0000000182f0d8b0 0x182e26000 + 948400 
4 CoreFoundation     0x0000000182e2e2d8 0x182e26000 + 33496 
5 CFNetwork      0x0000000183597b40 0x1834e9000 + 715584 
6 Foundation      0x0000000183957860 0x18384a000 + 1103968 
7 libsystem_pthread.dylib   0x0000000182b9432c 0x182b92000 + 9004 
8 libsystem_pthread.dylib   0x0000000182b941f8 0x182b92000 + 8696 
9 libsystem_pthread.dylib   0x0000000182b92c38 0x182b92000 + 3128 

Thread 8: 
0 libsystem_kernel.dylib   0x0000000182a81dbc 0x182a60000 + 138684 
1 libsystem_pthread.dylib   0x0000000182b92fb0 0x182b92000 + 4016 
2 libsystem_pthread.dylib   0x0000000182b92c30 0x182b92000 + 3120 

Thread 0 crashed with ARM Thread State (64-bit): 
    x0: 0x0000000000000000 x1: 0x0000000000000000 x2: 0x0000000000000000 x3: 0x00000001c04e10b7 
    x4: 0x0000000182471afd x5: 0x000000016d8eb4b0 x6: 0x000000000000006e x7: 0xffffffffffffffec 
    x8: 0x0000000008000000 x9: 0x0000000004000000 x10: 0x0000000182b9963c x11: 0x0000000000000003 
    x12: 0xffffffffffffffff x13: 0x0000000000000001 x14: 0x0000000182a07557 x15: 0x0000000000000010 
    x16: 0x0000000000000148 x17: 0x00000000ffffffff x18: 0x0000000000000000 x19: 0x0000000000000006 
    x20: 0x00000001b3804b80 x21: 0x000000016d8eb4b0 x22: 0x0000000000000303 x23: 0x00000001b3804c60 
    x24: 0x00000001c401f6a0 x25: 0x0000000000000000 x26: 0x0000000000000001 x27: 0x0000000000000000 
    x28: 0x000000016d8ebb28 fp: 0x000000016d8eb410 lr: 0x0000000182b95354 
    sp: 0x000000016d8eb3e0 pc: 0x0000000182a81348 cpsr: 0x00000000 

편집 : axisLabels를 할당하기 전에 할당 된 plotSpace를 가진되었다 무엇

*** Assertion failure in -[CPTXYAxis orthogonalCoordinateViewLowerBound:upperBound:], /Users/ric/Documents/Project/Pods/CorePlot/framework/Source/CPTXYAxis.m:128 
2017-11-21 09:35:42.790995-0500 Counting[808:591102] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'The orthogonalRange was nil in orthogonalCoordinateViewLowerBound:upperBound:' 
*** First throw call stack: 
(0x182f67d38 0x18247c528 0x182f67c0c 0x1838f6c24 0x1028d21d4 0x1028d2634 0x102833918 0x102835934 0x1027f2d30 0x1027f0510 0x1027f04b4 0x1027eda48 0x1027eccc8 0x18c377bfc 0x18c3777d4 0x18c4fce28 0x18c41ee04 0x18c41ea34 0x18c41e95c 0x18c375000 0x186f450b4 0x186f49194 0x186eb7f24 0x186ede340 0x186edf180 0x182f0f8b8 0x182f0d270 0x182f0d82c 0x182e2e2d8 0x184cbff84 0x18c3db880 0x102795218 0x18295256c) 
libc++abi.dylib: terminating with uncaught exception of type NSException 
+0

충돌의 원인은 무엇입니까? 충돌 로그의 관련 부분을 게시 할 수 있습니까? –

+0

@EricSkroch 나는 충돌 로그 정보로 업데이트했고, 나는 아무것도 놓치지 않았 으면 좋겠다. – Marquisk2

+0

크래시 로그 어디에도 코어 플롯이 표시되지 않습니다. 그것은 UIKit에서 추락했습니다. –

답변

0

.

이 코드 줄을 레이블 할당 위로 이동하면 문제가 해결되었습니다. rightY.plotSpace = rightAxisPlotSpace;

이것은 위에서 작성한 코드입니다.

CPTXYAxis *rightY = [[CPTXYAxis alloc] init]; 
// Configure the right y-axis 
rightY.labelingPolicy = CPTAxisLabelingPolicyNone; 
rightY.title = NSLocalizedStringFromTable(@"Time (Sec)", @"Scores", @"Time in seconds label for scores"); 
rightY.titleTextStyle = axisTitleStyle; 
rightY.titleOffset = 23.0f; 
rightY.axisLineStyle = axisLineStyle; 
rightY.tickDirection = CPTSignPositive; 
rightY.labelingPolicy = CPTAxisLabelingPolicyNone; 
rightY.labelOffset = 4.0f; 
rightY.majorTickLineStyle = axisLineStyle; 
rightY.majorTickLength = -5.0f; 
rightY.minorTickLength = -2.5f; 
rightY.axisConstraints = [CPTConstraints constraintWithUpperOffset:0]; 
rightY.plotSpace = rightAxisPlotSpace; 

NSInteger rightMajorIncrement = 1; 
NSInteger rightMinorIncrement = 1; 


CGFloat rightYMax = 12; // should determine dynamically based on max price 
NSMutableSet *rightYLabels = [NSMutableSet set]; 
NSMutableSet *rightYMajorLocations = [NSMutableSet set]; 
NSMutableSet *rightYMinorLocations = [NSMutableSet set]; 
for (NSInteger j = rightMinorIncrement; j <= rightYMax; j += rightMinorIncrement) { 
    NSUInteger mod = j % rightMajorIncrement; 
    if (mod == 0) { 
     CPTAxisLabel *label = [[CPTAxisLabel alloc] initWithText:[NSNumberFormatter localizedStringFromNumber:@(13 - j) numberStyle:NSNumberFormatterNoStyle] textStyle:rightY.labelTextStyle]; 
     NSDecimal rightLocation = CPTDecimalFromInteger(j); 
     label.tickLocation = rightLocation; 
     label.offset = 2; 
     if (label) { 
      [rightYLabels addObject:label]; 
     } 
     [rightYMajorLocations addObject:[NSDecimalNumber decimalNumberWithDecimal:rightLocation]]; 
    } else { 
     [rightYMinorLocations addObject:[NSDecimalNumber decimalNumberWithDecimal:CPTDecimalFromInteger(j)]]; 
    } 
} 
rightY.axisLabels = rightYLabels; 
관련 문제