2012-09-11 4 views
2

나는 슬픔의 원인이되는 핵심 음모에 문제가있어 인터넷을 샅샅이 뒤져서 해결책을 찾지 못했습니다. 나는 그것이 매우 단순한 감시 인 것을 두려워한다. 그러나 나의 인생 동안 나는 그것이 무엇인지 해결할 수 없다.코어 플롯에서 둘 이상의 맞춤 라벨을 사용하는 방법은 무엇입니까?

핵심 플롯에서 사용자 지정 레이블을 설정하면 관련된 배열에 눈금 위치 및 레이블 같은 올바른 데이터가 채워지더라도 레이블 중 하나만 눈금 위치 0에 나타납니다.

customLabels 배열에 수동으로 newLabels을 입력하여 사용자 정의 레이블 루틴을 우회하여이 작업을 수행 했으므로 어딘가에 기본 루틴이 누락 될까봐 두려워합니다.

2012년 9월 11일 10시 39분 9월

라벨 11

2012년 9월 11일 : 10 : 39 : 23.725 SnoozeBaby [C07 12000]

NSUInteger labelLocation = 0; 
NSMutableArray *customLabels = [[NSMutableArray alloc] initWithCapacity:[self.days count]]; 


for (NSNumber *tickLocation in self.customTickLocations) 
{ 

    CPTAxisLabel *newLabel = [[CPTAxisLabel alloc] initWithText:[self.dateLabels objectAtIndex:labelLocation] textStyle:axisTextStyle]; 
newLabel.tickLocation = [tickLocation decimalValue]; 
    int i = [tickLocation intValue]; 

    newLabel.offset = 5.0f; 
    newLabel.rotation = M_PI/4; 

    [customLabels addObject:newLabel]; 
    NSLog(@"Label is %@", [self.dateLabels objectAtIndex:labelLocation]); 

    labelLocation = labelLocation + 1; 


    NSLog(@"Tick Location is %i", i); 
} 
NSLog(@"Number of labels is %i", [customLabels count]); 

axisSet.xAxis.axisLabels = [NSSet setWithArray:customLabels]; 
axisSet.xAxis.majorTickLocations = [NSSet setWithArray:self.customTickLocations]; 

NSLog(@"I have set customlabels"); 

내 로그입니다 : 23.725 SnoozeBaby [12000 : C07] : 39 : 위치 눈금 0

2012년 9월 11일 10 23.725 SnoozeBaby [12000 : C07] : 39 : 라벨

2012년 9월 11일 구월

10 10 23.726 스누즈 베이비 [ 12000 : 39 : C07] 눈금 위치 150

2012년 9월 11일 10 23.726 SnoozeBaby [12000 : 39 : 라벨 C07] 번호 2

2012년 9월 11일 10 23.728 SnoozeBaby [12000 : C07] 당신이 CPTAxisLabelingPolicyNoneCPTAxis 라벨 정책을 설정

답변

1

customlabels 있습니까 설정 한?. 이렇게하지 않으면 레이블을 볼 수 없습니다.

두 번째로 주목해야 할 점은 반복 당 만들려는 CPTAxisLabel 개체를 각각 릴리스하지 않는다는 것입니다.

나는이 테스트를하지 않은하지만 당신이 먼저 레이블 위치를 설정해야한다고 말할 것이다 :

axisSet.xAxis.majorTickLocations = [NSSet setWithArray:self.customTickLocations]; 
axisSet.xAxis.axisLabels = [NSSet setWithArray:customLabels]; 
+1

많은 감사 엘 개발자를. 나는 CPTAxisLabelingPolicyNone을 가지고 있었고, 뒤늦은 시각에 더 많은 코드를 보여줘야했습니다. 내 문제는 CGFloat 변수를 사용하여 plotSpace.XRange에 대한 xMax 범위를 설정했지만 xMax가 자체를 0으로 설정하도록 [fetchResults count]를 전달하는 것으로 밝혀졌습니다. 나는 컴파일러가 경고를 던지기 때문에 그것을 놓쳤다. 시간을내어 도와 주셔서 감사합니다! – user1662478

관련 문제