Develop iOS library dropdown refresh-wcpullrefreshcontrol

Source: Internet
Author: User

Original blog, reproduced please indicate the source
Blog.csdn.net/hello_hwc
My GitHub
Https://github.com/wenchenhuang/WCPullRefreshControl

Objective:
Writing iOS code for a while, it is time to write a few GitHub libraries, that is, to exercise their own, but also to help the people in need.
This library is a drop-down refresh library, it took about 10 hours of time to develop, did a screen adaptation, rotation adaptation, the design of some of their own animation, API design changed 3 times. Finally, the first version is submitted to GitHub.
Address

Several

Characteristics:

    • Adaptable to a wide range of screen sizes
    • Suitable for a variety of scrollview (Uiscrollview,uitableview,uiwebview)
    • Support Device rotation
    • Supports a mix of up to 12 drop-down refreshes (3 kinds of progress,4 refreshing,3*4=12)
    • Supports block and delegate two ways of passing events
    • Support for ScrollView with navigation bar

It's easy to use.

    1. Drag and drop the classes file to the project.
    2. #import "WCSimplePullRefreshControl.h" where needed, and implement Uiscrollviewdelegate
    3. Save a Wcsimplepullrefreshcontrol property
    4. Initialize, if the event is passed using a proxy, set delegate to self
    5. Call updatewhenscrolldidenddraging in scrollviewdidenddragging; call Scrollviewdidscroll in Scrollviewdidscroll
    6. At the end of the refresh, call finishrefreshingsuccessully:

Example one using block to pass events
The default style is used here

 @interface demotableview() <uiscrollviewdelegate>@property(Strong,nonatomic) Wcsimplepullrefreshcontrol * PULLREFRESH;@end @implementation demotableview -(void) viewdidload{ Self. Pullrefresh= [[Wcsimplepullrefreshcontrol alloc] Initwithscrollview: Self. TableViewaction:^{[ SelfPerformselector:@selector(reset) Withobject:NilAfterdelay:2.0]; }];} -(void) reset{[ Self. PullrefreshFinishrefreshingsuccessully:YES];} -(void) Scrollviewdidenddragging: (Uiscrollview*) ScrollView Willdecelerate: (BOOL) decelerate{[ Self. PullrefreshUpdatewhenscrolldidenddraging];} -(void) Scrollviewdidscroll: (Uiscrollview*) scrollview{[ Self. PullrefreshUpdatewhenscrollviewscroll];}

Mode two using agent to pass events
Custom styles

 @interface demotableview() <uiscrollviewdelegate,  Wcpullrefreshcontroldelegate>@property(Strong,nonatomic) Wcsimplepullrefreshcontrol * PULLREFRESH;@end @implementation demotableview -(void) viewdidload{ Self. Pullrefresh= [[Wcsimplepullrefreshcontrol alloc] Initwithscrollview: Self. TableViewAction:NULLProgressitem:wcprogressitemtypemagicsquare Refreshingitem:wcrefreshingitemtypemagicsquare lastUpdate:NilShowlastupdate:NOtextcolor:[UicolorBluecolor] itemcolor:[UicolorGraycolor] Pullheight: -]; Self. Pullrefresh. Delegate= Self;} -(void) reset{[ Self. PullrefreshFinishrefreshingsuccessully:YES];} -(void) Scrollviewdidenddragging: (Uiscrollview*) ScrollView Willdecelerate: (BOOL) decelerate{[ Self. PullrefreshUpdatewhenscrolldidenddraging];} -(void) Scrollviewdidscroll: (Uiscrollview*) scrollview{[ Self. PullrefreshUpdatewhenscrollviewscroll];} -(void) Didstartrefreshingwithscrollview: (Uiscrollview*) scrollview{[ SelfPerformselector:@selector(reset) Withobject:NilAfterdelay:2.0];}@end

Subsequent
If you find a bug, please leave a message in this blog, or email: [Email protected]

Develop iOS library dropdown refresh-wcpullrefreshcontrol

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.