CN108694066A - A kind of method that tableView delays refresh - Google Patents

A kind of method that tableView delays refresh Download PDF

Info

Publication number
CN108694066A
CN108694066A CN201810439848.2A CN201810439848A CN108694066A CN 108694066 A CN108694066 A CN 108694066A CN 201810439848 A CN201810439848 A CN 201810439848A CN 108694066 A CN108694066 A CN 108694066A
Authority
CN
China
Prior art keywords
tableview
refresh
version number
delay
kreloadver
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.)
Granted
Application number
CN201810439848.2A
Other languages
Chinese (zh)
Other versions
CN108694066B (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

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 present invention relates to the methods that a kind of tableView delays refresh, and include the following steps:Initialize an overall situation version number kReloadVer;Whether judge, which currently allows to carry out delay, is refreshed LazyLoading;If it is not allowed, the operation for refreshing entire tableView is then executed, if it is allowed, then executing following operation:The value of global version number kReloadVer adds one, generate temporary version ver, value is the same as current global version number, call dispatch_after methods, refresh tasks are made to be added to queue and delay execution, by the way of caching temporary variable in iOS closures, temporary version number and global version number are compared, the refresh requests of repetition are abandoned.The present invention can cache the principle of temporary variable using in iOS closures, and repetitive requests are abandoned by comparing the temporary version number of caching and global version number, to achieve the purpose that delay executes, save system resource, delay refreshing effect is good, is convenient for later maintenance.

Description

A kind of method that tableView delays refresh
Technical field
The present invention relates to tableView optimisation techniques field, specifically a kind of method that tableView delays refresh.
Background technology
In the project development of iOS system, the most used class should count tableView, tableView in the iOS pages Namely UITableView classes, referred to as table view(List control), a behavior content element Cell of tableView, and many Cell can divide Do to have a header Header and footer Footer again with component part Section, each Section or more, many Section then constitute whole table Table, certain Table and also have Header and Footer.App's on the market is big now Most interfaces are all paved by tableView.
TableView is the high-level view in iOS, is inherited in ScrollView, therefore its institute with ScrollView It is functional.The representation formats of tableView are divided to two kinds of Plain and Grouped two kinds of styles.TableView provides two kinds of agencies Class delegate and dataSource.
The Local hydrodynamic unit logic of tableView depends on three letters typically to realizing certain some or one group of effect Number, reload, delete, insert.Many animation effects dazzled very much of tableView are realized with this.
The refreshing of tableView common are following several:
The first refreshes:Refresh entire UITableView, self.tableView reloadData;
Second of refreshing:Refresh the cell of part;
Such as:Refresh first cell of first section
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects: indexPath,nil] withRowAnimation:UITableViewRowAnimationFade];
The third refreshes:Local hydrodynamic unit section;
Such as:Refresh the 0th section
NSIndexSet *indexSet = [[NSIndexSet alloc] initWithIndex:0];
[self.tableView reloadSections:indexSet withRowAnimation: UITableViewRowAnimationFade];。
Under certain data interaction scenes, it may appear that the case where frequently user interface is refreshed, and frequently refreshing can make User's interface card is obtained, reduced performance influences user experience, needs to control the opportunity of refreshing.
Invention content
In view of the deficiencies in the prior art, refresh the purpose of the present invention is to provide a kind of tableView delays Method can cache the principle of temporary variable using in iOS closures, the temporary version number by that will cache and global version number It compares to abandon repetitive requests, to achieve the purpose that delay executes, saves system resource, delay refreshing effect is good, is convenient for the later stage It safeguards.
To achieve the above objectives, the technical solution adopted by the present invention is that:
A kind of method that tableView delays refresh, which is characterized in that include the following steps:
Initialize an overall situation version number kReloadVer;
Whether judge, which currently allows to carry out delay, is refreshed LazyLoading;
If it is not allowed, the operation for refreshing entire tableView is then executed,
If it is allowed, then executing following operation:
The value of global version number kReloadVer adds one,
Temporary version ver, the same current overall situation version number kReloadVer of value are generated,
Dispatch_after methods are called, refresh tasks is made to be added to queue and delay execution,
By the way of caching temporary variable in iOS closures, temporary version ver is cached,
When dispatch_after closures are called, temporary version ver and overall situation version number kReloadVer are compared, If unequal, illustrate there are new dispatch_after methods called, abandon the refresh requests of repetition, realize that delay is held The purpose that row refreshes.
Based on the above technical solution, the refresh requests for abandoning repetition realize that delay executes the purpose refreshed, It specifically includes:
Judge whether temporary version ver and overall situation version number kReloadVer are identical,
If it is different, then after showing this delay, and have invoked delay operation, then call discard methods to abandon this operation,
If identical, further judge currently whether refreshing, current non-Flushing status then calls p_ ReloadTableView methods execute tableView and refresh.
Based on the above technical solution, when executing the operation for refreshing entire tableView, reloaddata is in data It is called immediately after source DataSource changes.
Based on the above technical solution, the global version number kReloadVer initial values are defaulted as 0.
Based on the above technical solution, the temporary version ver is written in iOS closures and is cached.
The method that tableView delays of the present invention refresh can cache temporary variable using in iOS closures Principle, by the way that the temporary version number of caching and global version number's comparison are abandoned repetitive requests, to reach the mesh that delay executes , system resource is saved, delay refreshing effect is good, is convenient for later maintenance.
Description of the drawings
The present invention has following attached drawing:
The flow chart of Fig. 1 present invention.
Specific implementation mode
Below in conjunction with attached drawing, invention is further described in detail.
As shown in Figure 1, the method that tableView delays of the present invention refresh, includes the following steps:
Initialize an overall situation version number kReloadVer;
Whether judge, which currently allows to carry out delay, is refreshed LazyLoading;
If it is not allowed, the operation for refreshing entire tableView is then executed,
If it is allowed, then executing following operation:
The value of global version number kReloadVer adds one,
Temporary version ver, the same current overall situation version number kReloadVer of value are generated,
Dispatch_after methods are called, refresh tasks is made to be added to queue and delay execution,
By the way of caching temporary variable in iOS closures, temporary version ver is cached,
When dispatch_after closures are called, temporary version ver and overall situation version number kReloadVer are compared, If unequal, illustrate there are new dispatch_after methods called, abandon the refresh requests of repetition, realize that delay is held The purpose that row refreshes.
IOS closures are exactly the Block of iOS, can also make function variable, block that can be buffered in the outside of closure timing Variable numerical value, when closure when calling by the way that the variable value of caching and current variable value are compared, come Realize the judgement of certain conditions.The present invention in this way realizes the refreshing of delay tableView, and effective solution is short Due to there is the problem of multiple network request returns cause tableView frequently to refresh in time, by caching a version ver number Value, when closure is called, compare current value and cache size proves that new request returns if different, then can be with Ignore this refreshing.
Based on the above technical solution, the refresh requests for abandoning repetition realize that delay executes the purpose refreshed, It specifically includes:
Judge whether temporary version ver and overall situation version number kReloadVer are identical,
If it is different, then after showing this delay, and have invoked delay operation, then call discard methods to abandon this operation,
If identical, further judge currently whether refreshing, current non-Flushing status then calls p_ ReloadTableView methods execute tableView and refresh.
Based on the above technical solution, when executing the operation for refreshing entire tableView, reloaddata is in data It is called immediately after source DataSource changes.
Based on the above technical solution, the global version number kReloadVer initial values are defaulted as 0.
Based on the above technical solution, the temporary version ver is written in iOS closures and is cached.
The content not being described in detail in this specification belongs to the prior art well known to professional and technical personnel in the field.

Claims (5)

1. a kind of method that tableView delays refresh, which is characterized in that include the following steps:
Initialize an overall situation version number kReloadVer;
Whether judge, which currently allows to carry out delay, is refreshed LazyLoading;
If it is not allowed, the operation for refreshing entire tableView is then executed,
If it is allowed, then executing following operation:
The value of global version number kReloadVer adds one,
Temporary version ver, the same current overall situation version number kReloadVer of value are generated,
Dispatch_after methods are called, refresh tasks is made to be added to queue and delay execution,
By the way of caching temporary variable in iOS closures, temporary version ver is cached,
When dispatch_after closures are called, temporary version ver and overall situation version number kReloadVer are compared, If unequal, illustrate there are new dispatch_after methods called, abandon the refresh requests of repetition, realize that delay is held The purpose that row refreshes.
2. the method that tableView delays as described in claim 1 refresh, it is characterised in that:The refreshing for abandoning repetition Request is realized that delay executes the purpose refreshed, is specifically included:
Judge whether temporary version ver and overall situation version number kReloadVer are identical,
If it is different, then after showing this delay, and have invoked delay operation, then call discard methods to abandon this operation,
If identical, further judge currently whether refreshing, current non-Flushing status then calls p_ ReloadTableView methods execute tableView and refresh.
3. the method that tableView delays as described in claim 1 refresh, it is characterised in that:It executes and refreshes entirely When the operation of tableView, reloaddata is called immediately after data source DataSource changes.
4. the method that tableView delays as described in claim 1 refresh, it is characterised in that:The overall situation version number KReloadVer initial values are defaulted as 0.
5. the method that tableView delays as described in claim 1 refresh, it is characterised in that:The temporary version ver, It is cached in write-in iOS closures.
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 true CN108694066A (en) 2018-10-23
CN108694066B 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)

Citations (9)

* 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
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

Patent Citations (9)

* 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
US20080189302A1 (en) * 2007-02-07 2008-08-07 International Business Machines Corporation Generating database representation of markup-language document
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
TOMMYYAPHETS: ""lazy懒加载(延迟加载)UITableView"", 《HTTPS://BLOG.CSDN.NET/HMT20130412/ARTICLE/DETAILS/32173215》 *
VISHALKALOLA1: ""Lazy Loading and MBProgressHUD"", 《HTTPS://GITHUB.COM/VISHALKALOLA1/LAZYLOADINGAPPANDMBPROGRSSHUD》 *

Also Published As

Publication number Publication date
CN108694066B (en) 2021-04-27

Similar Documents

Publication Publication Date Title
WO2019114833A1 (en) Method, device, terminal and storage medium for processing application
Chintapalli et al. Benchmarking streaming computation engines: Storm, flink and spark streaming
US9367601B2 (en) Cost-based optimization of configuration parameters and cluster sizing for hadoop
WO2018177235A1 (en) Block chain consensus method and device
CN108595254B (en) Query scheduling method
CN107197053A (en) A kind of load-balancing method and device
Shen et al. Defuse: A dependency-guided function scheduler to mitigate cold starts on faas platforms
Petrov et al. Adaptive performance model for dynamic scaling Apache Spark Streaming
Liu et al. Optimizing shuffle in wide-area data analytics
CN113141283A (en) Network flow simulation test method, system and environment construction method
CN104363303A (en) Method for synchronizing asynchronously cached data
US20130061214A1 (en) Programmable intelligent storage architecture based on application and business requirements
CN110177144B (en) Method for copying application environment by one key based on private cloud
CN110727700A (en) Method and system for integrating multi-source streaming data into transaction type streaming data
CN108694066A (en) A kind of method that tableView delays refresh
Li et al. Statistical DRAM modeling
CN109491974A (en) Asynchronous blog management method and system and computer readable storage medium
CN106502842A (en) Data reconstruction method and system
CN112448855B (en) Method and system for updating block chain system parameters
CN112363774B (en) Method and device for configuring Storm real-time task
Morisawa et al. Flexible executor allocation without latency increase for stream processing in apache spark
CN111062681B (en) Course selection tour inspection method and device, server and storage medium
Rugwiro et al. Customization of virtual machine allocation policy using k-means clustering algorithm to minimize power consumption in data centers
Sliwko et al. Agocs—accurate google cloud simulator framework
McSherry et al. Naiad: The animating spirit of rivers and streams

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