UPDATE, insert TableView a row of data or section data

Source: Internet
Author: User

First, refresh the list

When a row of TableView data is modified, the data needs to be updated. There are two methods of refreshing:

(1) Refresh the entire list, that is, [self. TableView  reloaddata];

(2) Only the changed line is refreshed. Of course, this method is more efficient than the first method.

Specific code:

nsindexpath *refreshcell = [Nsindexpath indexpathforrow : 3 insection:0];

[ self. TableView reloadrowsatindexpaths: [nsarrayarraywithobjects: Refreshcell,nil] withrowanimation: Uitableviewrowanimationnone];

Second, insert a row of data data

Nsindexpath *refreshcell = [nsindexpathindexpathforrow: 3 insection : 0 ];

nsarray *insertindexpaths = [Nsarray Arraywithobjects:refreshcell,nil];

/// Also, add data to the data list

[_metermodelarray insertobject:d evice atindex : i+ 1 ];

[ self. TableView insertrowsatindexpaths: insertindexpathswithrowanimation: Uitableviewrowanimationright];

Third, refresh the data of a section

Nsindexset *refreshsection=[[nsindexsetalloc]initwithindex: 1]; // Refresh a second Section

[ self. TableView reloadsections: refreshsection withrowanimation: Uitableviewrowanimationautomatic];

iv. inserting a section data

According to the above, you can change it, no longer write.


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

UPDATE, insert TableView a row of data or section data

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.