IOS Refresh TableView method

Source: Internet
Author: User

Refresh UITableView

Methods: [Self.tableview Reloaddata];

Reloaddata is refreshing the entire uitableview, and sometimes we may need to refresh it locally. For example: Just refresh a cell, refresh only one section, and so on. This time in the call Reloaddata method, although the user can not see, but some waste resources.

Refresh Local cell

Method: Nsindexpath *indexpath = [Nsindexpath indexpathforrow:0 insection:0];

[Self.tableview Reloadrowsatindexpaths:[nsarray Arraywithobjects:indexpath,nil] WithRowAnimation: Uitableviewrowanimationfade];

This makes it easy to refresh the first cell of the first section. Although it looks like a lot of code, it does save resources. As few refreshes as possible, it is also an optimization of UITableView.

Partial Refresh section

Nsindexset *indexset = [[Nsindexset alloc] initwithindex:0];

[Self.tableview Reloadsections:indexset Withrowanimation:uitableviewrowanimationfade];

The above code is a No. 0 section refresh.

Refresh Animations

There are several animations to refresh UITableView:

typedef ns_enum (Nsinteger, uitableviewrowanimation) {

Uitableviewrowanimationfade,//Fade in

Uitableviewrowanimationright,//Slide right-in//slide

Uitableviewrowanimationleft,//slide in from left

Uitableviewrowanimationtop,//slide in from the top

Uitableviewrowanimationbottom,//slipped in from

Uitableviewrowanimationnone,//Available in IOS 3.0

Uitableviewrowanimationmiddle,//Available in IOS 3.2. Attempts to keep cell centered in the space it will/did occupy

Uitableviewrowanimationautomatic = +//Available in IOS 5.0. Chooses an appropriate animation style for you

};

IOS Refresh TableView method

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.