CN108694066B - TableView delayed refreshing method - Google Patents

TableView delayed refreshing method Download PDF

Info

Publication number
CN108694066B
CN108694066B CN201810439848.2A CN201810439848A CN108694066B CN 108694066 B CN108694066 B CN 108694066B CN 201810439848 A CN201810439848 A CN 201810439848A CN 108694066 B CN108694066 B CN 108694066B
Authority
CN
China
Prior art keywords
version number
refresh
temporary
kreloadver
tableview
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810439848.2A
Other languages
Chinese (zh)
Other versions
CN108694066A (en
Inventor
郭艳杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kuwo Technology Co Ltd
Original Assignee
Beijing Kuwo Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kuwo Technology Co Ltd filed Critical Beijing Kuwo Technology Co Ltd
Priority to CN201810439848.2A priority Critical patent/CN108694066B/en
Publication of CN108694066A publication Critical patent/CN108694066A/en
Application granted granted Critical
Publication of CN108694066B publication Critical patent/CN108694066B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces

Abstract

The invention relates to a tableView delayed refresh method, which comprises the following steps: initializing a global version number kReloadVer; judging whether lazyloloading is allowed to be performed at present; if not, the operation of refreshing the whole tableView is executed, and if the operation is allowed, the following operations are executed: adding one to the value of the global version number kReloadVer to generate a temporary version number ver, taking the value of the temporary version number ver and the current global version number, calling a dispatch _ after method to enable a refreshing task to be added into a queue and to be executed in a delayed mode, comparing the temporary version number with the global version number in a mode of caching a temporary variable in an iOS closure, and discarding repeated refreshing requests. The invention utilizes the principle that temporary variables can be cached in the iOS closure, discards repeated requests by comparing the cached temporary version number with the global version number, achieves the purpose of delaying execution, saves system resources, has good delayed refreshing effect and is convenient for later maintenance.

Description

TableView delayed refreshing method
Technical Field
The invention relates to the technical field of tableView optimization, in particular to a method for delaying refresh of tableView.
Background
In the project development of the iOS system, the most frequently used class in the iOS page corresponds to tablevew, which is also called a uitabeview class and is called a Table view (list control), one row of the tablevew is a content unit Cell, and many cells can form part of sections, each Section is further divided into a Header and a Footer, many sections form the whole Table, and certainly the Table also includes the Header and the Footer. Most interfaces of apps on the market today are tiled by tableView.
TableView is a high level view in iOS that inherits from ScrollView, so it has all the functionality of ScrollView. the tableView representation format is divided into two types, namely Plain and group. tableView provides two proxy classes, delete and dataSource.
the local refresh logic of tableView, usually to achieve some or a set of effects, relies on three functions, load, delete, insert. Many of the dazzling animation effects of tableView are achieved in this way.
the refresh of tableView is common to several:
first refresh: refresh the entire UITableView, self.
And a second refresh: refreshing local cells;
for example: refreshing the first cell of the first section
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationFade];
And a third refresh: locally refreshing a section;
for example: refresh 0 th section
NSIndexSet *indexSet = [[NSIndexSet alloc] initWithIndex:0];
[self.tableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationFade];。
Under certain data interaction situations, frequent refreshing of the user interface occurs, and the frequent refreshing causes the user interface to be stuck, the performance is reduced, the user experience is affected, and the refreshing time needs to be controlled.
Disclosure of Invention
Aiming at the defects in the prior art, the invention aims to provide a tableView delayed refreshing method, which achieves the purpose of delayed execution by using the principle that a temporary variable can be cached in an iOS closure and abandoning repeated requests by comparing the cached temporary version number with the global version number, saves system resources, has good delayed refreshing effect and is convenient for later maintenance.
In order to achieve the above purposes, the technical scheme adopted by the invention is as follows:
a method for deferred refresh of tableView, comprising the steps of:
initializing a global version number kReloadVer;
judging whether lazyloloading is allowed to be performed at present;
if not, an operation of refreshing the entire tableView is performed,
if so, performing the following operations:
the value of the global version number kReloadVer is incremented by one,
generating a temporary version number ver which takes the value of the temporary version number ver as the current global version number kReloadVer,
the dispatch _ after method is invoked, the flush task is added to the queue and delayed from executing,
caching the temporary version number ver by adopting a mode of caching temporary variables in the iOS closure,
when the dispatch _ after closure is called, the temporary version number ver is compared with the global version number kReloadVer, if the temporary version number ver is not equal to the global version number kReloadVer, a new dispatch _ after method is called, repeated refresh requests are abandoned, and the purpose of delaying the execution of refresh is achieved.
On the basis of the above technical solution, the discarding of the repeated refresh request achieves the purpose of delaying the execution of refresh, and specifically includes:
judging whether the temporary version number ver and the global version number kReloadVer are the same or not,
if the difference is different, the delay operation is called after the delay, the discard method is called to abandon the operation,
if the two states are the same, further judging whether the refresh is currently carried out or not, and if the refresh is not currently carried out, calling a p _ reloadTableView method to execute tableView refresh.
On the basis of the technical scheme, when the operation of refreshing the whole tableView is executed, the reloaddata is called immediately after the data source is changed.
On the basis of the technical scheme, the initial value of the global version number kReloadVer is defaulted to 0.
On the basis of the technical scheme, the temporary version number ver is written into the iOS closure for caching.
The method for delayed refreshing of tableView provided by the invention utilizes the principle that temporary variables can be cached in the iOS closure, discards repeated requests by comparing the cached temporary version number with the global version number, achieves the purpose of delayed execution, saves system resources, has good delayed refreshing effect and is convenient for later maintenance.
Drawings
The invention has the following drawings:
FIG. 1 is a flow chart of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings.
As shown in FIG. 1, the method for deferred refresh of tableView according to the present invention comprises the following steps:
initializing a global version number kReloadVer;
judging whether lazyloloading is allowed to be performed at present;
if not, an operation of refreshing the entire tableView is performed,
if so, performing the following operations:
the value of the global version number kReloadVer is incremented by one,
generating a temporary version number ver which takes the value of the temporary version number ver as the current global version number kReloadVer,
the dispatch _ after method is invoked, the flush task is added to the queue and delayed from executing,
caching the temporary version number ver by adopting a mode of caching temporary variables in the iOS closure,
when the dispatch _ after closure is called, the temporary version number ver is compared with the global version number kReloadVer, if the temporary version number ver is not equal to the global version number kReloadVer, a new dispatch _ after method is called, repeated refresh requests are abandoned, and the purpose of delaying the execution of refresh is achieved.
The iOS closure is a Block of the iOS, which may also be called a function variable, and the Block may cache values of external variables at the time of the closure, and when the closure is called, the determination of certain conditions is realized by comparing the cached variable values with the current variable values. The method realizes the refresh of the delayed tableView, effectively solves the problem of frequent refresh of the tableView caused by the return of a plurality of network requests in a short time, compares the current value with the cache value when the closure is called by caching a version ver value, and if the current value is different from the cache value, proves that a new request is returned, and can ignore the refresh.
On the basis of the above technical solution, the discarding of the repeated refresh request achieves the purpose of delaying the execution of refresh, and specifically includes:
judging whether the temporary version number ver and the global version number kReloadVer are the same or not,
if the difference is different, the delay operation is called after the delay, the discard method is called to abandon the operation,
if the two states are the same, further judging whether the refresh is currently carried out or not, and if the refresh is not currently carried out, calling a p _ reloadTableView method to execute tableView refresh.
On the basis of the technical scheme, when the operation of refreshing the whole tableView is executed, the reloaddata is called immediately after the data source is changed.
On the basis of the technical scheme, the initial value of the global version number kReloadVer is defaulted to 0.
On the basis of the technical scheme, the temporary version number ver is written into the iOS closure for caching.
Those not described in detail in this specification are within the skill of the art.

Claims (4)

1. A method for deferred refresh of tableView, comprising the steps of:
initializing a global version number kReloadVer;
judging whether lazyloloading is allowed to be performed at present;
if not, an operation of refreshing the entire tableView is performed,
if so, performing the following operations:
the value of the global version number kReloadVer is incremented by one,
generating a temporary version number ver which takes the value of the temporary version number ver as the current global version number kReloadVer,
the dispatch _ after method is invoked, the flush task is added to the queue and delayed from executing,
caching the temporary version number ver by adopting a mode of caching temporary variables in the iOS closure,
when the dispatch _ after closure is called, comparing the temporary version number ver with the global version number kReloadVer, if the temporary version number ver is not equal to the global version number kReloadVer, indicating that a new dispatch _ after method is called, discarding repeated refresh requests, and realizing the purpose of delaying the execution of refresh;
the discarding of the repeated refresh request realizes the purpose of delaying the execution of the refresh, and specifically includes:
judging whether the temporary version number ver and the global version number kReloadVer are the same or not,
if the difference is different, the delay operation is called after the delay, the discard method is called to abandon the operation,
if the two states are the same, further judging whether the refresh is currently carried out or not, and if the refresh is not currently carried out, calling a p _ reloadTableView method to execute tableView refresh.
2. The tablevew delayed refresh method of claim 1, wherein: when the operation of refreshing the whole tableView is executed, the reloaddata is called immediately after the data source DataSource is changed.
3. The tablevew delayed refresh method of claim 1, wherein: the initial value of the global version number kReloadVer is defaulted to 0.
4. The tablevew delayed refresh method of claim 1, wherein: and the temporary version number ver is written into the iOS closure for caching.
CN201810439848.2A 2018-05-09 2018-05-09 TableView delayed refreshing method Active CN108694066B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810439848.2A CN108694066B (en) 2018-05-09 2018-05-09 TableView delayed refreshing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810439848.2A CN108694066B (en) 2018-05-09 2018-05-09 TableView delayed refreshing method

Publications (2)

Publication Number Publication Date
CN108694066A CN108694066A (en) 2018-10-23
CN108694066B true CN108694066B (en) 2021-04-27

Family

ID=63846126

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810439848.2A Active CN108694066B (en) 2018-05-09 2018-05-09 TableView delayed refreshing method

Country Status (1)

Country Link
CN (1) CN108694066B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112287658A (en) * 2020-11-03 2021-01-29 深圳壹账通智能科技有限公司 Business data processing method and device, electronic equipment and medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8195736B2 (en) * 2006-08-08 2012-06-05 Opnet Technologies, Inc. Mapping virtual internet protocol addresses
CN103136201A (en) * 2011-11-22 2013-06-05 阿里巴巴集团控股有限公司 Page information display method and page information display device
CN103838593A (en) * 2012-11-22 2014-06-04 华为技术有限公司 Method and system for restoring virtual machine, controller, server and hosting host
CN105955777A (en) * 2016-05-03 2016-09-21 网易(杭州)网络有限公司 User interface refreshing method and device
CN106126260A (en) * 2016-07-01 2016-11-16 深圳云之家网络有限公司 A kind of delayed data loading method and device
CN106502589A (en) * 2016-10-21 2017-03-15 普元信息技术股份有限公司 The loading of caching or the system and method for persistence is realized based on cloud computing
CN107329795A (en) * 2017-06-23 2017-11-07 北京酷我科技有限公司 A kind of TableView optimization methods
CN107465707A (en) * 2016-06-03 2017-12-12 阿里巴巴集团控股有限公司 A kind of content refresh method and device of content distributing network

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080189302A1 (en) * 2007-02-07 2008-08-07 International Business Machines Corporation Generating database representation of markup-language document

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8195736B2 (en) * 2006-08-08 2012-06-05 Opnet Technologies, Inc. Mapping virtual internet protocol addresses
CN103136201A (en) * 2011-11-22 2013-06-05 阿里巴巴集团控股有限公司 Page information display method and page information display device
CN103838593A (en) * 2012-11-22 2014-06-04 华为技术有限公司 Method and system for restoring virtual machine, controller, server and hosting host
CN105955777A (en) * 2016-05-03 2016-09-21 网易(杭州)网络有限公司 User interface refreshing method and device
CN107465707A (en) * 2016-06-03 2017-12-12 阿里巴巴集团控股有限公司 A kind of content refresh method and device of content distributing network
CN106126260A (en) * 2016-07-01 2016-11-16 深圳云之家网络有限公司 A kind of delayed data loading method and device
CN106502589A (en) * 2016-10-21 2017-03-15 普元信息技术股份有限公司 The loading of caching or the system and method for persistence is realized based on cloud computing
CN107329795A (en) * 2017-06-23 2017-11-07 北京酷我科技有限公司 A kind of TableView optimization methods

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
"Lazy Loading and MBProgressHUD";vishalkalola1;《https://github.com/vishalkalola1/LazyLoadingAPPAndMBProgrssHud》;20171116;第1页代码段 *
"lazy懒加载(延迟加载)UITableView";TommyYaphetS;《https://blog.csdn.net/hmt20130412/article/details/32173215》;20140618;第1-8页 *

Also Published As

Publication number Publication date
CN108694066A (en) 2018-10-23

Similar Documents

Publication Publication Date Title
US10242022B1 (en) Systems and methods for managing delayed allocation on clustered file systems
TWI679547B (en) Block chain business acceptance and business consensus method and device
US20140334494A1 (en) Hardware hash table virtualization in multi-packet processor networking systems
US20150120925A1 (en) Lock elevation in a distributed file storage system
CN105868093B (en) A kind of log wiring method and server-side
JP2013524342A (en) Mapping RDMA semantics to high-speed storage
US20190187897A1 (en) Efficient sharing of non-volatile memory
CN108694066B (en) TableView delayed refreshing method
CN111124270A (en) Method, apparatus and computer program product for cache management
US20140082275A1 (en) Server, host and method for reading base image through storage area network
US20200210219A1 (en) Storage control method and storage controller for user individual service environment
US8904093B1 (en) Managing lifetime of limited usage storage devices in a caching system
US10977200B2 (en) Method, apparatus and computer program product for processing I/O request
CN104363303A (en) Method for synchronizing asynchronously cached data
CN105068817A (en) Method for writing data in storage device and storage device
CN106598502B (en) Data storage method and system
CN112069152A (en) Database cluster upgrading method, device, equipment and storage medium
CN109582460B (en) Redis memory data elimination method and device
CN114817090B (en) MCU communication management method and system with low RAM consumption
CN112241418A (en) Distributed database preprocessing method, agent layer, system and storage medium
CN113157738B (en) In-heap data cache synchronization method and device, computer equipment and storage medium
US9871732B2 (en) Dynamic flow control in multicast systems
US11467754B2 (en) Capacity expansion method and capacity expansion system based on dual-level list structure
KR102212512B1 (en) System for covert channel configuration base in software using mutex object in virtualization technique
CN107273188B (en) Virtual machine Central Processing Unit (CPU) binding method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant