Last week, the project to do the line chart, today thought to perfect it, set up a different data source to test, haha, also really encountered problems, that is, to set the number of vertices for the chart is 0 o'clock, the view is displayed or original, because the data is empty, it should be set to empty, So think about how to put the sub-view in the ScrollView case. Because the caption and vertex values are in label, you can delete the view. But the lines and dots are added to the layer by Bezier curves, and the layers of the view are deleted. But here's the problem, first remove the code:
int count = [self.layer.sublayers count]; for (int0; i<count; i++) { [self.layer.sublayers[i] removefromsuperlayer]; }
But the results are not ideal:
When multiple click on the day button, will slowly delete, feel strange, feel can be bitter force. Later asked Oliver, the great God is the great God, in a while to get the reason. The number of child layers in the parent view will be 1 each time a parent view is deleted, and if you delete it with the I index every time, you will miss some sublayers and the modifications will be perfect.
int count = [self.layer.sublayers count]; for (int0; i<count; i++) { [self.layer.sublayers[0] Removefromsuperlayer]; }
There are also the for-in and for (int i=0; ...) that the blog has mentioned before. The difference. Http://www.cnblogs.com/5ishare/p/4372398.html
I use the following code throughout the duration is also a hint error: is mutated while being enumerated traversal can not be deleted
for inch self.layer.sublayers) { [layer Removefromsuperlayer]; }
The correct code update is in the line chart that blog post
iOS Line Chart II