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.
- Drag and drop the classes file to the project.
- #import "WCSimplePullRefreshControl.h" where needed, and implement Uiscrollviewdelegate
- Save a Wcsimplepullrefreshcontrol property
- Initialize, if the event is passed using a proxy, set delegate to self
- Call updatewhenscrolldidenddraging in scrollviewdidenddragging; call Scrollviewdidscroll in Scrollviewdidscroll
- 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