iOS learning UITableView Scroll to the specified location
The method is simple:
-(void) Scrolltorowatindexpath: (Nsindexpath *) Indexpath atscrollposition: (uitableviewscrollposition) Scrollposition animated: (BOOL) animated
Here are some things to keep in mind:
If you need to get the TableView cell, the height, or the need to scroll tableview immediately after reloaddata, it is possible to execute code directly after Reloaddata.
Reloaddate does not wait for the TableView update to return, but returns immediately, then calculates the table height, gets the cell, and so on.
If the data in the table is very large and is not finished executing in a run loop, then the operation that requires TableView view data will be problematic.
Apple does not directly provide Reloaddata API, want the program to delay to reloaddata end in operation, you can use the following methods:
Method One:
[Self.tableview Reloaddata]; [Self.tableview layoutifneeded];//Refresh Complete
Method Two:
[Self.tableview Reloaddata];d ispatch_async (Dispatch_get_main_queue (), ^{ //Refresh complete});
The reloaddate is executed in the primary queue, and Dispatch_get_main_queue waits for the opportunity until the home row is idle.
Similar functions:
-(void) Scrolltorowatindexpath: (Nsindexpath *) Indexpath atscrollposition: (uitableviewscrollposition) Scrollposition animated: (BOOL) animated;
-(void) Scrolltonearestselectedrowatscrollposition: (uitableviewscrollposition) scrollposition animated: (BOOL) Animated;
-(void) Setcontentoffset: (Cgpoint) Contentoffset animated: (BOOL) animated; Animate at constant velocity to new offset
-(void) scrollRectToVisible: (cgrect) Rect animated: (BOOL) animated;
When using [TableView reloaddata]; When refreshing data, you cannot use the above function directly in the back. Reload
iOS learning UITableView Scroll to the specified location