UITableView is no stranger to iOS developers, and it's possible that your app uses many of its interfaces. About UITableView article, presumably already countless, nothing can see more. Especially the UITableView optimization article, it is worth pondering carefully.
UITableView is no stranger to iOS developers, and it's possible that your app uses many of its interfaces. About UITableView article, presumably already countless, nothing can see more. Especially the UITableView optimization article, it is worth pondering carefully.
Today we take a look at how to refresh UITableView, in general, refresh UITableView, we will call the Reloaddata method directly.
Refresh UITableView
[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
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 Development tips: Refresh UITableView