CN105677366B - The method that Infinite Cyclic rolls selection is realized based on UITableView in iOS system - Google Patents

The method that Infinite Cyclic rolls selection is realized based on UITableView in iOS system Download PDF

Info

Publication number
CN105677366B
CN105677366B CN201610108213.5A CN201610108213A CN105677366B CN 105677366 B CN105677366 B CN 105677366B CN 201610108213 A CN201610108213 A CN 201610108213A CN 105677366 B CN105677366 B CN 105677366B
Authority
CN
China
Prior art keywords
value
uitableview
tableview
alldataarraycount
newselectedobjectindex
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
CN201610108213.5A
Other languages
Chinese (zh)
Other versions
CN105677366A (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.)
Sichuan Changhong Electric Co Ltd
Original Assignee
Sichuan Changhong Electric 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 Sichuan Changhong Electric Co Ltd filed Critical Sichuan Changhong Electric Co Ltd
Priority to CN201610108213.5A priority Critical patent/CN105677366B/en
Publication of CN105677366A publication Critical patent/CN105677366A/en
Application granted granted Critical
Publication of CN105677366B publication Critical patent/CN105677366B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/34Graphical or visual programming

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The invention discloses a kind of based on the method that UITableView realization Infinite Cyclic rolls selection in iOS system, creates UITableView and view controller and is loaded, adds two agencies;Two NSMutableArray are added, save the data source for needing initial data and UITableView to be shown respectively;Add the variation of the data object quantity in integer variable record rolling process and the change in location of selected object;UITableView data source is set, all variables are initialized;Setting sliding rate of deceleration, closes both ends elastic effect, its dataSource is arranged;Corresponding method, the more value of the variable of new record scrolling position information are rewritten in view controller, updates UITableView data source, refresh the interface UI.The present invention realizes the circulating rolling function of UITableView List View.

Description

The method that Infinite Cyclic rolls selection is realized based on UITableView in iOS system
Technical field
Embodiments of the present invention are related to computer technology and field of software development, more specifically, embodiment party of the invention Formula is related to a kind of method for realizing that Infinite Cyclic rolls selection based on UITableView in iOS system.
Background technique
With the high speed development of internet and mobile application technology, smart phone and mobile application produce people's lives Far-reaching influence is given birth to, being related to field includes each side in browsing internet, traffic, house property information, shopping, smart home etc. Face, it may be said that mobile application is controlling daily life.Since Apple Inc.'s release iOS7 system in 2013, it is System style flattening, causes the trend of a burst of human-computer interaction style transformation, and simultaneous user recognizes interactive interface It is promoted, hommization, flattening, diversification, dynamic and visual, ultimate attainment smooth interaction are increasingly subject to people's favor.
During using UITableView for iOS system progress software development, although it, which is supplied to developer, to roll List View, but it can not provide circulating rolling function, when for when selecting object data amount huger, sometimes Need to realize one can satisfy can quickly be selected when user slides into bottom top cell object, due to primary TableView is unable to circulating rolling, so only manually sliding into top again, this greatly reduces the experience of user.Nothing By being that newest iOS9 system or pervious iOS version all have such functional defect.
Summary of the invention
Technical problem solved by the invention is that iOS system cannot provide the List View with circulating rolling function, when User can only manually slide into top again when list is slided into bottom, greatly reduce the experience of user.And roll view The rolling rate of figure can delay very much the update of dataSource to load fastly, influence very much user experience slowly.It is to be shown right due to needing As quantity difference, the data amount check selection of the dataSource of UITableView is problematic, and number selection will increase too much is answered It is born, and will lead to very little using Caton with memory.In order to realize circulating rolling, chosen after needing to record current scrolling Position, the more new demand of data source is rapid and accurate during scrolling, especially data interface portion end to end, updates not in time It will appear application interface Caton or display mistake.
In order to solve the above technical problems, an embodiment of the present invention adopts the following technical solutions:
A method of realizing that Infinite Cyclic rolls selection based on UITableView in iOS system, it includes following step It is rapid:
Step 1: first creating a type and be the UITableView of Plain, then create a view controller, then exist Load the UITableView of creation in view controller, and add act on behalf of UITableViewDataSource, UITableViewDelegate;
Step 2: two NSMutableArray of addition, wherein first preservation need initial data to be shown, second For the data source of UITableView;
Step 3: five integer variables of overall importance of addition record the variation of the data object quantity in entire rolling process And the change in location of selected object;
Step 4: the data source of UITableView is set in viewDidLoad method according to initial data quantity, initially Change all variables in step 3;
Step 5: the sliding rate of deceleration of UITableView being set, close both ends elastic effect, and it is set dataSource;
Step 6: scrollViewDidEndDragging:willDecelerate is rewritten in view controller: and ScrollViewDidEndDecelerating: method, the more value of the variable of new record scrolling position information;
Step 7: according to the variation of the value of correlated variables in step 6, updating the data source of UITableView, refresh UI circle Face can be completed and realize that Infinite Cyclic rolls selection function using UITableView.
It is above-mentioned to realize that Infinite Cyclic rolls in the method for selection based on UITableView in iOS system, described in step 2 Two NSMutableArray are substituted with NSArray.
It is above-mentioned to realize that Infinite Cyclic rolls in the method for selection based on UITableView in iOS system, five described in step 3 A integer variable of overall importance is at least one of the variable for having global modification and reading characteristic.
It is above-mentioned based in iOS system UITableView realize Infinite Cyclic roll in the method for selection, the step 4 and The specific steps of step 5 are as follows:
(1) allDataArray, dataSourceArray, allDataArrayCount are initialized;
(2) allDataArrayCount is judged, if passing through method addObjectsFromArray less than 99: repeating The data in allDataArray are loaded, update the value of allDataArrayCount until it is greater than 99;
(3) setting defaultIndex is that middle position i.e. 49, selectedObjectAtAllDataArrayIndex is 2, dataSourceArrayCount 99, pass through method setContentOffset: the offest that tableView is arranged is (0,60*abs(defaultIndex-2));
(4) updateTableViewDatasource method is called, the data source of tableView is updated dataSourceArray;
(5) be arranged tableView bounces be NO, decelerationRate 0.3, delegate and DataSource is self, and tableView is loaded on viewController.
It is above-mentioned to realize that Infinite Cyclic rolls in the method for selection based on UITableView in iOS system, described in step 6 ScrollViewDidEndDragging:willDecelerate: the realization step of method are as follows:
(1) when decelerate is NO, judge whether scrollView.contentOffset.y%60 is greater than 30, if It is (0, ((scrollView.contentOffset.y)/60+ greater than the value that scrollView.contentOffset is then arranged 1) (0, ((scrollView.contentOffset.y)/60) * 60 * 60), are otherwise provided as;
(2) value for updating currentIndex is scrollView.contentOffset.y/60+2;
(3) it obtains tableView has rolled how many row according to the value of currentIndex and defaultIndex, increases one newly A int type temporary variable newSelectedObjectIndex, value selectedObjectAtAllDataArrayIndex +(currentIndex-defaultIndex);When newSelectedObjectIndex has been greater than the element number of initial data When allDataArrayCount -1, the value for updating selectedObjectAtAllDataArrayIndex is NewSelectedObjectIndex-allDataArrayCount, if be not more than and newSelectedObjectIndex Less than 0, then selectedObjectAtAllDataArrayIndex value is allDataArrayCount+ NewSelectedObjectIndex, otherwise value is newSelectedObjectIndex;
(4) call method updateTableViewDatasource and updateTableView, updates tableView's Data source and the interface UI.
It is above-mentioned to realize that Infinite Cyclic rolls in the method for selection based on UITableView in iOS system, described in step 6 ScrollViewDidEndDecelerating: the realization step of method are as follows:
(1) when scrollView.dragging is NO, whether judge scrollView.contentOffset.y%60 Greater than 30, if more than be then arranged scrollView.contentOffset value be (0, ((scrollView.contentOffset.y)/60+1) * 60), be otherwise provided as (0, ((scrollView.contentOffset.y)/60)*60;
(2) value for updating currentIndex is scrollView.contentOffset.y/60+2;
(3) it obtains tableView has rolled how many row according to the value of currentIndex and defaultIndex, increases one newly A int type temporary variable newSelectedObjectIndex, value selectedObjectAtAllDataArrayIndex +(currentIndex-defaultIndex);When newSelectedObjectIndex has been greater than the element number of initial data When allDataArrayCount -1, the value for updating selectedObjectAtAllDataArrayIndex is NewSelectedObjectIndex-allDataArrayCount, if be not more than and newSelectedObjectIndex Less than 0, then selectedObjectAtAllDataArrayIndex value is allDataArrayCount+ NewSelectedObjectIndex, otherwise value is newSelectedObjectIndex;
(4) call method updateTableViewDatasource and updateTableView, updates tableView's Data source and the interface UI.
It is above-mentioned to realize that Infinite Cyclic rolls in the method for selection based on UITableView in iOS system, it is described The realization step of updateTableViewDatasource method are as follows:
(1) all the elements object of dataSourceArray is removed;
(2) it is recycled using for, cyclic variable i is decremented to 0 from defaultIndex, adds again to dataSourceArray Add preceding part object elements, in loop body use three integer temporary variables: offestIndex, sumIndex and TheObjectAtAllDataArrayIndex, offestIndex value are defaultIndex-i, and sumIndex value is selectedObjectAtAllDataArrayIndex–offestIndex;When sumIndex is less than 0, The value of theObjectAtAllDataArrayIndex is allDataArrayCount+sumIndex, otherwise its value is sumIndex;The theObjectAtAllDataArrayIndex object in allDataArray is finally passed through into method InsertObject:atIndex: it is inserted into the position that index is 0 in dataSourceArray;
(3) reuse for recycle added again to dataSourceArray after part object elements, cyclic variable j from DefaultIndex+1 is incremented to dataSourceArrayCount -1, and two integer temporary variables are stated in loop body The value of sumIndex and theObjectAtAllDataArrayIndex, sumIndex are j-defaultIndex+ SelectedObjectAtAllDataArrayIndex, when sumIndex is greater than allDataArrayCount -1, The value of theObjectAtAllDataArrayIndex is sumIndex- (allDataArrayCount-1) -1, otherwise its value is SumIndex finally adds the in allDataArray to dataSourceArray by addObject TheObjectAtAllDataArrayIndex object.
It is above-mentioned to realize that Infinite Cyclic rolls in the method for selection based on UITableView in iOS system, it is described The realization step of updateTableView method are as follows:
(1) reloadData method is sent to tableView, reloads the data in tableView data source;
(2) send setContentOffset:animated to tableView: it is (0,60*abs that offest, which is arranged, in method (defaultIndex-2)), animation effect animated therein is NO.
It is above-mentioned to realize that Infinite Cyclic rolls in the method for selection based on UITableView in iOS system, the Infinite Cyclic Roll selection refer to the last one data object being rolled in initial data after still be able to continue to roll, it is subsequent will be from first Data object continues to roll according to specified sequence.
It is above-mentioned to realize that Infinite Cyclic rolls in the method for selection based on UITableView in iOS system, the life of the variable Name is not limited to above-mentioned variable naming only for facilitating vivid explanation.
Compared with prior art, beneficial effects of the present invention first is that: the present invention provides one kind based in iOS system The method that UITableView realizes circulating rolling selection menu, not by showing on mobile device screen interface The cell number of UITableView influences, and allows user can be in the more situation of number of objects to be selected of list quickly It is rolled to the position of the object of desired selection, reduces the unnecessary slide of user, solving UITableView cannot recycle It rolls there is no the objective object for showing and choosing, UIPickerView is unable to the problem of plane circulation rolls, obtains software design It is more humanized, improve the experience of user.
Detailed description of the invention
Fig. 1 is to realize that Infinite Cyclic rolls the process of the method for selection the present invention is based on UITableView in iOS system Figure.
Specific embodiment
In order to make the objectives, technical solutions, and advantages of the present invention clearer, with reference to the accompanying drawings and embodiments, right The present invention is further elaborated.It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, and It is not used in the restriction present invention.
Embodiment
All it is that data source is fixed for UITableView under normal conditions, carries out data displaying by scrolling up and down , it then has been found that its data source changes in real time with rolling, changes its deviant after sliding, then this UITableView can be carried out Infinite Cyclic and roll, and the initial position of UITableView is allowed to be displaced to entire content first Middle section, scroll up and down it initially can, then pass through two Proxy Methods ScrollViewDidEndDragging:willDecelerate: and scrollViewDidEndDecelerating:, it is rolling Its data source is updated immediately after dynamic, resets deviant, after refreshing the interface UI, transforms to UITableView rolling The interface that active user sees, and these users be all it is imperceptible, user just can be allowed to feel that this UITableView can With the rolling of Infinite Cyclic.
The present invention realizes the operating procedure that UITableView Infinite Cyclic rolls as shown in Figure 1, mainly including following step It is rapid: step 1: creating a type first and be the UITableView of Plain, then create a view controller, in view control Load the UITableView of creation on device, and add act on behalf of UITableViewDataSource, UITableViewDelegate;Step 2: two NSMutableArray of addition, wherein first preservation need to be to be shown original Data, second data source for UITableView;Step 3: five integer variables of overall importance of addition record entire roll The variation of data object quantity in the process and the change in location of selected object;Step 4: the root in viewDidLoad method The data source of UITableView, all variables in initialization step 3 are set according to initial data quantity;Step 5: setting The sliding rate of deceleration of UITableView closes both ends elastic effect, and its dataSource is arranged;Step 6: in view ScrollViewDidEndDragging:willDecelerate is rewritten in controller: and ScrollViewDidEndDecelerating: method, the more value of the variable of new record scrolling position information;Step 7: according to step The variation of the value of correlated variables in rapid 6 updates the data source of UITableView, refreshes the interface UI, use can be completed UITableView realizes that Infinite Cyclic rolls selection function.
Below above-mentioned each step is carried out being more clear complete description.
Step 1: a new engineering is created in Xcode, creates a view controller (UIViewController), It is created in this view controller and loads UITableView example tableView, a type Plain, and add generation Manage UITableViewDataSource, UITableViewDelegate.
Step 2: two variable data arrays (NSMutableArray) are added under view controller, one of save is owned Data object allDataArray, another be tableView data source dataSourceArray.
Step 3: added under view controller 5 integer variables of overall importance shaped like: defaultIndex, currentIndex、selectedObjectAtAllDataArrayIndex、allDataArrayCount、 DataSourceArrayCount, wherein defaultIndex indicates that current selected object exists before sliding occurs Position in dataSourceArray, current selected object is in dataSourceArray after currentIndex indicates sliding Position, selectedObjectAtAllDataArrayIndex indicate institute's selected object in initial data allDataArray In position, require to update this value after each sliding, allDataArrayCount indicates all data objects Number, dataSourceArrayCount then indicate the data object number of the dataSource of tableView, the two are mainly used In the correctness for guaranteeing that data are shown.
Step 4: the data source of tableView being set in viewDidLoad method and assigns initial value to each variable, is It allows the rolling and the data correctness for keeping rolling process that tableView can be smooth, needs to guarantee DataSourceArrayCount be equal to 99, if the object number of allDataArray less than 99, then only needing to be repeated Load, the specific method is as follows:
(1) allDataArray, dataSourceArray, allDataArrayCount are initialized;
(2) allDataArrayCount is judged, if passing through method addObjectsFromArray less than 99: repeating The data in allDataArray are loaded, update the value of allDataArrayCount until it is greater than 99;
(3) when allDataArrayCount is greater than 99, setting defaultIndex is middle position i.e. 49, SelectedObjectAtAllDataArrayIndex is 2, dataSourceArrayCount 99, passes through method SetContentOffset: the offest that tableView is arranged is (0,60*abs (defaultIndex-2));
(4) updateTableViewDatasource method is called, the data source of tableView is updated dataSourceArray;
(5) be arranged tableView bounces be NO, decelerationRate 0.3, delegate and DataSource is self, and preferably tableView is loaded on viewController.
Step 5: configuration tableView has carried out the part attribute setting of tableView in step s 4, including has closed Closing both ends elastic effect setting bounces is no, and the rate of deceleration decelerationRate that rolling is arranged is 0.3, setting Delegate and dataSource is view controller where UITableView;It needs to pass through later NumberOfSectionsInTableView: the method setting TableView of UITableViewDataSource only has 1 Section passes through method tableView:numberOfRowsInSection: be arranged tableView cell number be _ DataSourceArray.count passes through the tableView of UITableViewDelegate: HeightForRowAtIndexPath: the height that cell is arranged in method is 1/5th of tableView height, passes through method TableView:cellForRowAtIndexPath: the content of each cell is configured.
Step 6 includes step 6-1 and step 6-2, as follows:
Step 6-1: rewriteeing scrollViewDidEndDragging:willDecelerate: method, guarantees TableView can timely update data source when rolling at a slow speed, obtain current selected object by the deviant after sliding first Position currentIndex in data source can be obtained further according to the position defaultIndex of previously stored last time It, finally can be again to current selected object in the position selectedObjectAtAllDataArrayIndex of initial data The new data source dataSourceArray of tableView is obtained, scrollViewDidEndDragging is rewritten: WillDecelerate: method is specific as follows:
(1) when decelerate is NO, judge whether scrollView.contentOffset.y%60 is greater than 30, if It is (0, ((scrollView.contentOffset.y)/60+ greater than the value that scrollView.contentOffset is then arranged 1) (0, ((scrollView.contentOffset.y)/60) * 60 * 60), are otherwise provided as;
(2) value for updating currentIndex is scrollView.contentOffset.y/60+2;
(3) it obtains tableView has rolled how many row according to the value of currentIndex and defaultIndex, can increase newly One int type temporary variable newSelectedObjectIndex, value are selectedObjectAtAllDataArrayIndex+(currentIndex-defaultIndex);When When newSelectedObjectIndex has been greater than the element number allDataArrayCount -1 of initial data, update The value of selectedObjectAtAllDataArrayIndex is newSelectedObjectIndex- AllDataArrayCount, if newSelectedObjectIndex is not more than the element number of initial data AllDataArrayCount -1 and newSelectedObjectIndex is less than 0, then SelectedObjectAtAllDataArrayIndex value is allDataArrayCount+ NewSelectedObjectIndex, otherwise value is newSelectedObjectIndex;
(4) call method updateTableViewDatasource and updateTableView, updates tableView's Data source and the interface UI.
Step 6-2: it is similar with step 6-1, scrollViewDidEndDecelerating: method is rewritten, when TableView obtains new currentIndex in quick sliding, according to the defaultIndex of preservation, can be obtained and works as Preceding selected object can finally be retrieved in the position selectedObjectAtAllDataArrayIndex of initial data TableView new data source dataSourceArray, rewrite scrollViewDidEndDecelerating: method is as follows:
(1) when scrollView.dragging is NO, whether judge scrollView.contentOffset.y%60 Greater than 30, if more than be then arranged scrollView.contentOffset value be (0, ((scrollView.contentOffset.y)/60+1) * 60), be otherwise provided as (0, ((scrollView.contentOffset.y)/60)*60;
(2) value for updating currentIndex is scrollView.contentOffset.y/60+2;
(3) it obtains tableView has rolled how many row according to the value of currentIndex and defaultIndex, can increase newly One int type temporary variable newSelectedObjectIndex, value are selectedObjectAtAllDataArrayIndex+(currentIndex-defaultIndex);When When newSelectedObjectIndex has been greater than the element number allDataArrayCount -1 of initial data, update The value of selectedObjectAtAllDataArrayIndex is newSelectedObjectIndex- AllDataArrayCount, if newSelectedObjectIndex is not more than the element number of initial data AllDataArrayCount -1 and newSelectedObjectIndex is less than 0, then SelectedObjectAtAllDataArrayIndex value is allDataArrayCount+ NewSelectedObjectIndex, otherwise value is newSelectedObjectIndex;
(4) call method updateTableViewDatasource and updateTableView, updates tableView's Data source and the interface UI.
Above-mentioned steps 4, step 6, step 7 have invoked method updateTableViewDatasource, to update TableVide data source dataSourceArray, method updateTableViewDatasource are implemented as follows:
(1) all the elements object of dataSourceArray is removed;
(2) it is recycled using for, cyclic variable i is decremented to 0 from defaultIndex, adds again to dataSourceArray Add preceding part object elements, in loop body use three integer temporary variables: offestIndex, sumIndex and TheObjectAtAllDataArrayIndex, offestIndex value are defaultIndex-i, and sumIndex value is selectedObjectAtAllDataArrayIndex–offestIndex;When sumIndex is less than 0, The value of theObjectAtAllDataArrayIndex is allDataArrayCount+sumIndex, otherwise its value is sumIndex;The theObjectAtAllDataArrayIndex object in allDataArray is finally passed through into method InsertObject:atIndex: it is inserted into the position that index is 0 in dataSourceArray;
(3) reuse for recycle added again to dataSourceArray after part object elements, cyclic variable j from DefaultIndex+1 is incremented to dataSourceArrayCount -1, and two integer temporary variables are stated in loop body The value of sumIndex and theObjectAtAllDataArrayIndex, sumIndex are j-defaultIndex+ SelectedObjectAtAllDataArrayIndex, when sumIndex is greater than allDataArrayCount -1, The value of theObjectAtAllDataArrayIndex is sumIndex- (allDataArrayCount-1) -1, otherwise its value is SumIndex finally adds the in allDataArray to dataSourceArray by addObject TheObjectAtAllDataArrayIndex object.
The method updateTableView that above-mentioned steps 6-1 and step 6-2 are called, to refresh the interface UI, method UpdateTableView is implemented as follows:
(1) reloadData method is sent to tableView, reloads the data in tableView data source;
(2) send setContentOffset:animated to tableView: it is (0,60*abs that offest, which is arranged, in method (defaultIndex-2)), animation effect animated therein is NO.
Step 7: according to the variation of the value of correlated variables in step 6, updating the data source of UITableView, refresh UI circle Face can be completed and realize that Infinite Cyclic rolls selection function using UITableView.
Although reference be made herein to invention has been described for explanatory embodiment of the invention, however, it is to be understood that ability Field technique personnel can be designed that a lot of other modification and implementations, these modifications and implementations will fall in the application public affairs Within the scope and spirit opened.It more specifically, can be to the group of theme combination layout in range disclosed in the present application A variety of variations and modifications are carried out at component and/or layout.In addition to variations and improvements to the component parts and or layout, To those skilled in the art, other purposes also will be apparent.

Claims (4)

1. a kind of method for realizing that Infinite Cyclic rolls selection based on UITableView in iOS system, it is characterised in that it includes Following steps:
Step 1: first creating a type and be the UITableView of Plain, then create a view controller, then in view Load the UITableView of creation on controller, and add act on behalf of UITableViewDataSource, UITableViewDelegate;
Step 2: two NSMutableArray of addition, wherein first preservation needs initial data to be shown, second is The data source of UITableView;
Step 3: addition five integer variables of overall importance, record the data object quantity in entire rolling process variation and by The change in location of selected object;
Step 4: the data source of UITableView, initialization step are set in viewDidLoad method according to initial data quantity All variables in rapid 3;
Step 5: the sliding rate of deceleration of UITableView being set, close both ends elastic effect, and it is set dataSource;
Step 6: scrollViewDidEndDragging:willDecelerate is rewritten in view controller: and ScrollViewDidEndDecelerating: method, the more value of the variable of new record scrolling position information;
Step 7: according to the variation of the value of correlated variables in step 6, updating the data source of UITableView, refresh the interface UI, i.e., It is achievable to realize that Infinite Cyclic rolls selection function using UITableView;The specific steps of step 4 and step 5 are as follows:
(1) allDataArray, dataSourceArray, allDataArrayCount are initialized;
(2) allDataArrayCount is judged, if passing through method addObjectsFromArray less than 99: repeating to load Data in allDataArray update the value of allDataArrayCount until it is greater than 99;
(3) setting defaultIndex is i.e. 49, the selectedObjectAtAllDataArrayIndex in middle position 2, DataSourceArrayCount is 99, passes through method setContentOffset: be arranged tableView offest be (0, 60*abs(defaultIndex-2));
(4) updateTableViewDatasource method is called, the data source of tableView is updated dataSourceArray;The realization step of the updateTableViewDatasource method are as follows:
(a) all the elements object of dataSourceArray is removed;
(b) it is recycled using for, cyclic variable i is decremented to 0 from defaultIndex, before adding again to dataSourceArray Partial objects element, in loop body use three integer temporary variables: offestIndex, sumIndex and TheObjectAtAllDataArrayIndex, offestIndex value are defaultIndex-i, and sumIndex value is selectedObjectAtAllDataArrayIndex–offestIndex;When sumIndex is less than 0, The value of theObjectAtAllDataArrayIndex is allDataArrayCount+sumIndex, otherwise its value is sumIndex;The theObjectAtAllDataArrayIndex object in allDataArray is finally passed through into method InsertObject:atIndex: it is inserted into the position that index is 0 in dataSourceArray;
(c) reuse for recycle added again to dataSourceArray after part object elements, cyclic variable j from DefaultIndex+1 is incremented to dataSourceArrayCount -1, and two integer temporary variables are stated in loop body The value of sumIndex and theObjectAtAllDataArrayIndex, sumIndex are j-defaultIndex+ SelectedObjectAtAllDataArrayIndex, when sumIndex is greater than allDataArrayCount -1, The value of theObjectAtAllDataArrayIndex is sumIndex- (allDataArrayCount-1) -1, otherwise its value is SumIndex finally adds the in allDataArray to dataSourceArray by addObject TheObjectAtAllDataArrayIndex object;
(5) bounces that tableView is arranged is NO, decelerationRate 0.3, delegate and dataSource For self, tableView is loaded on viewController;
ScrollViewDidEndDragging:willDecelerate described in step 6: the realization step of method are as follows:
(1) when decelerate is NO, judge whether scrollView.contentOffset.y%60 is greater than 30, if more than The value that scrollView.contentOffset is then arranged is (0, ((scrollView.contentOffset.y)/60+1) * 60) (0, ((scrollView.contentOffset.y)/60) * 60, are otherwise provided as;
(2) value for updating currentIndex is scrollView.contentOffset.y/60+2;
(3) it obtains tableView has rolled how many row according to the value of currentIndex and defaultIndex, increases one newly Int type temporary variable newSelectedObjectIndex, value selectedObjectAtAllDataArrayIndex+ (currentIndex-defaultIndex);When newSelectedObjectIndex has been greater than the element number of initial data When allDataArrayCount -1, the value for updating selectedObjectAtAllDataArrayIndex is NewSelectedObjectIndex-allDataArrayCount, if be not more than and newSelectedObjectIndex Less than 0, then selectedObjectAtAllDataArrayIndex value is allDataArrayCount+ NewSelectedObjectIndex, otherwise value is newSelectedObjectIndex;
(4) call method updateTableViewDatasource and updateTableView updates the data of tableView Source and the interface UI;The realization step of the updateTableView method are as follows:
(a) reloadData method is sent to tableView, reloads the data in tableView data source;
(b) send setContentOffset:animated to tableView: it is (0,60*abs that offest, which is arranged, in method (defaultIndex-2)), animation effect animated therein is NO;
ScrollViewDidEndDecelerating described in step 6: the realization step of method are as follows:
(1) when scrollView.dragging is NO, judge whether scrollView.contentOffset.y%60 is greater than 30, if more than be then arranged scrollView.contentOffset value be (0, ((scrollView.contentOffset.y)/60+1) * 60), be otherwise provided as (0, ((scrollView.contentOffset.y)/60)*60;
(2) value for updating currentIndex is scrollView.contentOffset.y/60+2;
(3) it obtains tableView has rolled how many row according to the value of currentIndex and defaultIndex, increases one newly Int type temporary variable newSelectedObjectIndex, value selectedObjectAtAllDataArrayIndex+ (currentIndex-defaultIndex);When newSelectedObjectIndex has been greater than the element number of initial data When allDataArrayCount -1, the value for updating selectedObjectAtAllDataArrayIndex is NewSelectedObjectIndex-allDataArrayCount, if be not more than and newSelectedObjectIndex Less than 0, then selectedObjectAtAllDataArrayIndex value is allDataArrayCount+ NewSelectedObjectIndex, otherwise value is newSelectedObjectIndex;
(4) call method updateTableViewDatasource and updateTableView updates the data of tableView Source and the interface UI.
2. the method according to claim 1 for realizing that Infinite Cyclic rolls selection based on UITableView in iOS system, It is characterized in that two NSMutableArray described in step 2 are substituted with NSArray.
3. the method according to claim 1 for realizing that Infinite Cyclic rolls selection based on UITableView in iOS system, It is characterized in that five integer variables of overall importance described in step 3 are at least one had in the variable of global modification reading characteristic Kind.
4. the method according to claim 1 for realizing that Infinite Cyclic rolls selection based on UITableView in iOS system, It still is able to it is characterized in that the Infinite Cyclic rolls after selection refers to the last one data object being rolled in initial data Continue to roll, it is subsequent to continue to roll from first data object according to specified sequence.
CN201610108213.5A 2016-02-26 2016-02-26 The method that Infinite Cyclic rolls selection is realized based on UITableView in iOS system Active CN105677366B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610108213.5A CN105677366B (en) 2016-02-26 2016-02-26 The method that Infinite Cyclic rolls selection is realized based on UITableView in iOS system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610108213.5A CN105677366B (en) 2016-02-26 2016-02-26 The method that Infinite Cyclic rolls selection is realized based on UITableView in iOS system

Publications (2)

Publication Number Publication Date
CN105677366A CN105677366A (en) 2016-06-15
CN105677366B true CN105677366B (en) 2019-01-11

Family

ID=56306005

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610108213.5A Active CN105677366B (en) 2016-02-26 2016-02-26 The method that Infinite Cyclic rolls selection is realized based on UITableView in iOS system

Country Status (1)

Country Link
CN (1) CN105677366B (en)

Families Citing this family (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106648640A (en) * 2016-12-09 2017-05-10 武汉斗鱼网络科技有限公司 Method and device for simplifying codes
CN106648642A (en) * 2016-12-09 2017-05-10 武汉斗鱼网络科技有限公司 Infinite page scrolling method of slide view in IOS client end and system
CN108614739A (en) * 2016-12-12 2018-10-02 阿里巴巴集团控股有限公司 A kind of method and device for transmitting message
CN106815015B (en) * 2016-12-21 2020-06-16 武汉斗鱼网络科技有限公司 Method and system for organizing views in IOS
CN106843992A (en) * 2016-12-22 2017-06-13 武汉斗鱼网络科技有限公司 Data managing method and device
CN107219983B (en) * 2017-06-20 2020-07-31 武汉斗鱼网络科技有限公司 List display method and device
CN107329795A (en) * 2017-06-23 2017-11-07 北京酷我科技有限公司 A kind of TableView optimization methods
CN107656729B (en) * 2017-08-31 2020-04-28 深圳壹账通智能科技有限公司 List view updating apparatus, method and computer-readable storage medium
CN108391075B (en) * 2018-02-27 2020-10-30 北京酷我科技有限公司 Method for refreshing video playing Cell without interval
CN108762866B (en) * 2018-05-09 2021-08-13 北京酷我科技有限公司 Short audio rolling display method
CN108762759B (en) * 2018-05-28 2022-03-25 北京酷我科技有限公司 Statistical method for exposure presentation rate of content cell
CN108762842A (en) * 2018-05-28 2018-11-06 北京小米移动软件有限公司 Method for extracting content, device, terminal and storage medium
CN108958624B (en) * 2018-06-26 2021-06-29 福建天泉教育科技有限公司 Method and terminal for realizing scroll view response
CN109783329B (en) * 2018-12-04 2022-07-19 深圳市酷达通讯有限公司 Application program blank data prompting method and system and terminal equipment
CN110175023A (en) * 2019-05-28 2019-08-27 四川长虹电器股份有限公司 Method and system based on the multistage nested linkage of the UIScrollView in iOS system
CN113051012B (en) * 2021-03-18 2022-12-02 平安普惠企业管理有限公司 Data loading method, device, equipment and medium based on list view
CN114281222A (en) * 2021-12-15 2022-04-05 贵阳语玩科技有限公司 iOS-based multi-view level management method, system and construction method
CN114860140B (en) * 2022-03-18 2023-05-02 恒鸿达科技有限公司 Configuration-based lvgl interface cyclic sliding method and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102520918A (en) * 2011-09-27 2012-06-27 深圳市五巨科技有限公司 Method and device for increasing list refreshing frequency
CN104636136A (en) * 2015-01-12 2015-05-20 沈文策 Group simulation method based on Plain type of UITableView in iOS system
CN105354013A (en) * 2014-08-18 2016-02-24 阿里巴巴集团控股有限公司 Application interface rendering method and apparatus

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9116766B2 (en) * 2013-07-31 2015-08-25 Sap Se Extensible applications using a mobile application framework

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102520918A (en) * 2011-09-27 2012-06-27 深圳市五巨科技有限公司 Method and device for increasing list refreshing frequency
CN105354013A (en) * 2014-08-18 2016-02-24 阿里巴巴集团控股有限公司 Application interface rendering method and apparatus
CN104636136A (en) * 2015-01-12 2015-05-20 沈文策 Group simulation method based on Plain type of UITableView in iOS system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
[iOS_Dev] UITableView 水平放置 自动循环滚动;iOS_Dev_OYXJ;《https://blog.csdn.net/u014558625/article/details/41598615》;20141129;第1-4页
iOS UIScrollView滚动视图/无限循环滚动/自动滚动;珊小瑚;《https://blog.csdn.net/shanhu_t/article/details/50359469》;20151219;第1-2页

Also Published As

Publication number Publication date
CN105677366A (en) 2016-06-15

Similar Documents

Publication Publication Date Title
CN105677366B (en) The method that Infinite Cyclic rolls selection is realized based on UITableView in iOS system
CN104583946B (en) Graphic package editing machine based on physics
Klokmose et al. Webstrates: shareable dynamic media
Rädle et al. Codestrates: Literate computing with webstrates
CN102356375B (en) Smooth layout animation of continuous and non-continuous properties
US20080303827A1 (en) Methods and Systems for Animating Displayed Representations of Data Items
CA2922860A1 (en) System and method for streamlining user interface development
CN103530018A (en) Establishment method of widget interfaces in android operating system and mobile terminal
CN110088718A (en) The interface transformation of dynamic generation
US20080303826A1 (en) Methods and Systems for Animating Displayed Representations of Data Items
CN105677351B (en) The compatible display methods of multiwindow and device
CN110221899A (en) A kind of adjusting method of user interface, apparatus and system
WO2015184736A1 (en) Method and terminal for transforming background picture of touchscreen device
CN106471572A (en) A kind of method of simultaneous voice and virtual acting, system and robot
WO2014099275A1 (en) Methods and systems for overriding graphics commands
CN112445564A (en) Interface display method, electronic device and computer readable storage medium
WO2014099277A1 (en) Methods and systems for overriding graphics commands
CN114780077A (en) Webpage visual editing device and method
CN113900760A (en) Popup window display method and device
CN110007919A (en) A kind of dynamic density screen adaptation method and system for the automatic airport of unmanned plane
CN109164968A (en) Exchange method and device based on list
CN106371732A (en) Method for controlling electronic curtain and electronic terminal
WO2014099301A1 (en) Methods and systems for overriding graphics commands
KR102092156B1 (en) Encoding method for image using display device
CN113850891A (en) Animation playing processing method, device, equipment and system

Legal Events

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