iOS Learning path-drop-down refresh and pull-up load more

Source: Internet
Author: User

iOS Learning path-drop-down refresh and pull-up loading more about

In this paper, I will share with you the application of the form content commonly used in the drop-down refresh and pull-up loading more ways to implement the function.

Content 1. What are the methods of implementation and the merits of each method

Friends who have used the American group, the popular reviews should have noticed that when you swipe up the form, more stores are loaded into your form, and when you slide the top of the form, it refreshes the contents of the form and gets the latest information from the Web. Add more features with drop-down refresh and pull-up to enable apps to get more information from users and get the latest information. So how can this function be implemented, please follow the author continue to look down.

At present, the main implementation methods are as follows

A Refresh method in the Uikit of 1.uirefreshcontrol:ios, the most basic and primitive

2. Self-defined: can make personalized refresh tool, but more complex and prone to problems, not recommended novice and for the rush to use the temporary people.

3.ah3dpullrefresh: Simple drop-down refresh/load control, with 3D effect, easy to use, if the ARC environment needs to set up a bit

Specific settings such as

Setting UISCROLLVIEW+AH3DPULLREFRESH.M in the compile sources of build phases will work properly with the flags-fno-objc-arc.

4.MJRefresh: Convenient and quick, it is the most convenient and most compatible refresh loading tool

5. Other Open Source libraries: There are many open source libraries online, including the above recommended 3 and 4 Also, there are many kinds of online, interested words can go to Cocoachina or other open source code of the site to search, choose a suitable for their own situation.

2. Concrete examples

Next, please with the author to see Mjrefresh and a writer from the Cocoachina download a very good-looking name for the yalsunnyrefreshcontroll of the concrete implementation of the process.

The first is to add a drop-down refresh to add the Yalsunnyrefreshcontroll folder to the project

Then you need to add a drop-down to refresh the. h file to introduce a header file that is #import "YALSunnyRefreshControl.h", and @property a Yalsunnyrefreshcontrol object for the class.

:

The Yalsunnyrefreshcontrol is then initialized and associated with the UITableView or uicollectionview that is required to implement the Refresh function, with the following specific code:

Finally, the images needed to refresh the animation are introduced, which are downloaded with the code and can be used with his or her own

The results shown in the final implementation are as follows:

When the table is pulled, there will be a sunrise and a house animation appearing above the table, isn't it nice? And the content has also been refreshed, this tool is really easy to use and good-looking.

Next, I use the Mjrefresh implementation of the pull-down form to load more data from the network and display the functionality on the form.

The first step, as before, is to add the Mjrefresh package to the project and introduce it into the. m file that needs to use it.

Then, create a new Mjrefresh global variable in the file, and then initialize and associate with TableView, with the following code:

The role of my Code [self startdownload] is to load 10 data locally from the _offset bar on the web, _offset+=10 then call [self startdownload] to load more 10 data into my app, After downloading, remember to call TableView's Reloaddata method to display the newly loaded data to the form.

When the load is complete, you also need to call a stop loading method as the end, otherwise you can not do the next load, in your load data to your TableView datasource method finally called the following method

The above two are the invocations of my loading and flushing end methods, preferably called TableView's Reloaddata method before calling;

This completes the implementation of the load and refresh functionality, which is loaded as follows:

The author said that the Apple is still not proficient, will only use the screenshot ...

3. Conclusion

In short, the above is my pull refresh and pull-up loading function How to achieve the personal summary, if onlookers think I have said the wrong and insufficient places, also please advice, can contact me through the blog, or in the article leave a comment, thank you ~.

iOS Learning path-drop-down refresh and pull-up load more

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.