VBPieChart을 Objective C 언어로 사용하고 있습니다. 내가 좋아하는, 세그먼트 컨트롤의 valueChange
에 차트를 보여주는 해요 :VBPieChart - removeFromSuperView가 작동하지 않습니다 (차트 숨기기)
- (IBAction)segmentControlAction:(UISegmentedControl *)sender
{
switch ([sender selectedSegmentIndex])
{
case 0:
[self showPieChart:NO];
_tableViewForCount.hidden = NO;
[_tableViewForCount reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationRight];
break;
case 1:
_tableViewForCount.hidden = YES;
[self showPieChart:YES];
break;
default:
NSLog(@"None");
break;
}
}
과 showPieChart
방법은 같이 간다 : VBPieChart
이후
- (void) showPieChart:(Boolean)visible
{
VBPieChart *chart = [[VBPieChart alloc] initWithFrame:CGRectMake(0, 0, 250, 250)];
chart.center = self.view.center;
// Setup some options:
[chart setHoleRadiusPrecent:0.3]; /* hole inside of chart */
// Prepare your data
NSMutableArray *chartValues = [[NSMutableArray alloc]initWithObjects: @{@"name":@"Apples", @"value":@50, @"color":[UIColor redColor]},
@{@"name":@"Pears", @"value":@20, @"color":[UIColor blueColor]},
@{@"name":@"Oranges", @"value":@40, @"color":[UIColor orangeColor]},
@{@"name":@"Bananas", @"value":@70, @"color":[UIColor purpleColor]}, nil
];
if (visible)
{
chart.center = self.view.center;
// Present pie chart with animation
[chart setChartValues:chartValues animation:YES duration:0.4 options:VBPieChartAnimationFan];
[self.view addSubview:chart];
}
else
{
// remove chart
[chart removeFromSuperView];
}
}
는 UIView의 단지 사용자 정의 서브 클래스이며,이 작업을해야합니다. 그러나 나는 어떤 성공도 얻지 못하고있다.
나는 또한 [chart setAlpha:0.0];
과 마찬가지로 [chart setHidden:YES];
을 시도했지만 아직 행운은 없습니다.
어떤 도움을 주시면 감사하겠습니다. 사용자가 세그먼트 인덱스 0으로 전환했을 때 차트를 숨기거나 제거하고 싶습니다.
감사합니다.
고맙습니다. 매력처럼 작동합니다. –
@RajD 해피 코딩을 가장 환영합니다! –