[iOS] tableview 下拉更新

1: Download the third party Library
https://github.com/samvermette/SVPullToRefresh


2: import header file
In the class that is in needImport this header file will be able to use the drop-down refresh, pull up the load

#import “UIScrollView+SVPullToRefresh.h”


3: Adding Pull to Refresh

[tableView addPullToRefreshWithActionHandler:^{
    // prepend data to dataSource, insert cells at top of table view
    // call [tableView.pullToRefreshView stopAnimating] when done
}];

滿神奇的,居然這樣子就可以使用了。

只是訊息都還是英文的,需要另外設中文化。

string 加入這3組就ok了。

“Pull to refresh…” = “Pull to refresh…”;
“Release to refresh…” = “Release to refresh…”;
“Loading…” = “Loading…”;


下面這個我也看不懂,我直接跳過。

custom display text

SetTitle:@ [_tableView.pullToRefreshView "pull down to refresh" forState:SVPullToRefreshStateTriggered]; 
SetTitle:@ [_tableView.pullToRefreshView "Refresh" forState:SVPullToRefreshStateStopped]; 
SetTitle:@ forState:SVPullToRefreshStateLoading] "no load in the..." [_tableView.pullToRefreshView;

 

Customization

The pull to refresh view can be customized using the following properties/methods:

@property (nonatomic, strong) UIColor *arrowColor;
@property (nonatomic, strong) UIColor *textColor;
@property (nonatomic, readwrite) UIActivityIndicatorViewStyle activityIndicatorViewStyle;

- (void)setTitle:(NSString *)title forState:(SVPullToRefreshState)state;
- (void)setSubtitle:(NSString *)subtitle forState:(SVPullToRefreshState)state;
- (void)setCustomView:(UIView *)view forState:(SVPullToRefreshState)state;

You can access these properties through your scroll view’s pullToRefreshView property.

For instance, you would set the arrowColor property using:

tableView.pullToRefreshView.arrowColor = [UIColor whiteColor];

下面這個我也看不懂,我直接跳過。

custom refresh when the animation

View UIView* = alloc] initWithFrame:CGRectMake [[UIView (0, 0, 200, 40)]; 
View.backgroundColor = blueColor] [UIColor; 
BeginAnimations:nil context:nil] [UIView; 
SetAnimationDuration:3] [UIView; 
View.alpha = 0.5; 
CommitAnimations] [UIView; 
SetCustomView:view forState:SVPullToRefreshStateAll] [_tableView.pullToRefreshView;

 

 


from github:
https://github.com/samvermette/SVPullToRefresh

相關文章

寫留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *