iOS Line Chart II

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.