Pull-up and pull-down refresh

Source: Internet
Author: User

Pull-up and pull-down refresh

I. Pull up and refresh 1. Why do I need to pull up and refresh? To read some old (more) data, you need to pull and refresh to load more data. 2. Pull and refresh are always displayed at the bottom of tableView? TableFootView is always at the bottom of tableView. You can use it to construct 3. pull up and refresh Business Logic 3.1 when all the pull and refresh controls (footView) are displayed, load more data 3.2 interfaces and build the desired style with xib as needed. 4. how can I determine whether the pull and refresh controls are fully displayed? 4.1 The condition for full display is: offset = content height + bottom TabBar height-screen height 4.2. You can use the scrollView proxy method to listen for scrolling and obtain the offset-(void) scrollViewDidScroll :( UIScrollView *) scrollView; 4.3 when the current offset> = offset, the up-refresh control is fully displayed. we found that the scroll bar will be blocked at the top and bottom of the page. How can we solve this problem? You can set the additional scroll area of the scroll bar to 5.2. How can I get this attribute? Go to the tableView header file to find the UIEdgeInsets keyword. If no 5.3 is found, go to the scrollView parent control of tableView and find the scrollIndicatorInsets attribute. If you set it, you will get 6 done. the data returned by the Server 6.1 contains a serial number ID (which you can understand). The serial number ID is incremental and new data is stored in the database, ID numbers are incremented by 6.3 to display the data displayed on the page from top to bottom, and ID numbers are decreased, that is, the lower the data, the earlier the data is 6.4, we only need to get the ID of the bottom row of the data, and request the data before this number, we can get the ID of the previous data 6.5, the server will give us, we only need to record it and we can get 6.6 to load more data. We only need to add this ID to the request parameter. 7.bug: if we keep clicking and refresh, many requests will be sent, how can this problem be solved when data duplication occurs? 7.1 Is a bool attribute record loading more data? If it is loading, you do not need to send the request again. Where is the attribute record 7.2? Controller? Record in the controller is not good, pull and refresh the business logic of the control, it is best to record in the control when loading the value is yes after loading the value is no if the record in the Controller, if you use pull-up refresh elsewhere, you need to drag the controller. If the coupling is too high, the system starts to run 7.3 and the pull-up refresh control will be displayed. How can this problem be solved? If there is no data at the beginning, pulling and refreshing will be displayed on tableView, and data 7.4 will be loaded. How can this problem be solved? First, hide the footView. After loading the data for the first time, refresh the table and load the 7.5 space from the xib. Is the size incorrect? You can delete the auto-scaling property. 8. Change the content of the space in the xib to be refreshed based on whether the property is fully displayed. 2. pull-down refresh 1. Why do you perform pull-down refresh? Users want to see the latest data 2. pull-down refresh, where to add the control? On headerView? Cannot be added to headerView. Generally, headerView is left to the ad space. 3. What is the use of the pull-down refresh control? Use a view and set the y value of the view to a negative number to display it at the top, and add the view to tableView with the spring effect. 4. the business logic 4.1 drop-down control of the drop-down control needs to refresh the data 4.2 when dragging to determine whether it is completely displayed, completely displayed, drop-down control text and arrow Direction 5. the full display condition of the drop-down control is 5.1. How can I determine that the full display of the drop-down control is complete? It also uses the offset (negative value) offsetY =-(navigation bar height + drop-down control height) because there is an offset of 5.2 in the height of the navigation bar and the current offset is obtained using the proxy method <= offsetY, 6 is displayed completely. how to modify the text and arrow direction of the drop-down control 6.1 define a BOOL attribute record in the control whether it is fully displayed 6.2 in the Controller (in the proxy method) to determine whether it is fully displayed, if the value is set to yes 6.3, the link is connected to obtain the control to be changed. Rewrite the set Method of the BOOL attribute. Modify the text and arrow method in the method. 6.4 modify the arrow method using transform, in normal cases, the negative angle (less than 180) should be counter-clockwise, But we set-180 and found it to rotate clockwise ?? Apple determines the critical value and rotates at the smallest angle. We only need to add a small value to 180. 7. pull-up conflicts 7.1 when the network is slow, the user first pulls and refresh, there will be a bug in the pull-down refresh, will cause data disorder, how to solve? 7.2 you only need to clear all the previous data before refresh and refresh the data. Keep the latest data. 7.3 assume that after the network is pulled slowly, back now pull down the original data for 51 50 49 48 47 pull server should return data 46 45 44 43 42 drop-down server should return data 53 52 51 50 49 final server will return data at the same time changed to 53 52 51 50 49 46 45 44 43 42 data will be lost two 7.4 how to solve? Only one request can be sent at the same time. 7.5 defines the network manager object. When a new request is sent, the previous request is canceled // the previous request [self. mgr. tasks makeObjectsPerformSelector: @ selector (cancel)]; 8. when is it necessary to refresh the data 8.1 that is not completely displayed by refreshing the data drop-down control? How can I listen to the new data 8.2 when it is needed to load the latest data? Proxy method: // stop dragging-(void) scrollViewDidEndDragging :( UIScrollView *) scrollView willDecelerate :( BOOL) When decelerate 8.3 is requesting the latest data, you do not need to send any more request data (drag the drop-down control all the time). Similarly, you can set a BOOL attribute in the control to record whether data is being loaded. 8.4 refresh the latest data, there may be only one latest data at a time, existing data 50 49 48 47 46 loading data 51 50 49 48 47 loading data arrangement 51 50 49 48 47 50 48 47 46 this will cause data duplication because after the data is converted into a model, traverse the model and add the model to the array. The original array may have these models. 8.5 solve the problem of data duplication before loading new data, you only need to clear all the previous data. use a third-party framework to integrate pull-up and refresh the source code directly.
1-(void) setupRefreshView 2 {3 // pull-down refresh 4 // when the float is released and the pull-down refresh is fully displayed, the pull-down refresh 5 MJRefreshNormalHeader * header = [MJRefreshNormalHeader headerWithRefreshingTarget: self refreshingAction: @ selector (loadNewData)]; 6 // the transparency of the drop-down control changes automatically (completely transparent) 7. header. automaticallyChangeAlpha = YES; 8 self. tableView. mj_header = header; 9 10 // pull up refresh 11 MJRefreshAutoNormalFooter * footer = [empty footerWithRefreshingTarget: self refreshingAction: @ selector (loadMoreData)]; 12 // automatically hide the control, hide 13 footer when no data exists. automaticallyHidden = YES; 14 self. tableView. mj_footer = footer; 15} 16 17 Note: The control will always exist when the up/down refresh is triggered, we need to manually hide 18 19 and hide 20 when the data request is successful // pull and refresh 21 [self. tableView. mj_footer endRefreshing]; 22 23 24 // refresh 25 [self. tableView. mj_header endRefreshing];

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.