J'utilise VBPieChart, en langage Objective C. Je montre le tableau sur valueChange
d'un contrôle segmenté, comme:VBPieChart - removeFromSuperView ne fonctionne pas (masquer le graphique)
- (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;
}
}
et la méthode showPieChart
va comme:
- (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];
}
}
Depuis VBPieChart
est juste une sous-classe personnalisée de UIView, cela devrait fonctionner. Mais je ne reçois aucun succès. J'ai également essayé [chart setHidden:YES];
ainsi que , mais toujours pas de chance.
Toute aide serait appréciée. Je veux juste cacher/enlever le tableau quand l'utilisateur est revenu à l'index de segment 0.
Merci.
Merci. fonctionne comme un charme. –
@RajD Le plus apprécié Codage heureux! –