2013年9月24日 星期二
UITableView 實作下拉更新 用refresh control
在 YourViewController.h中加入
@property (nonatomic, strong) UIRefreshControl *refreshControl;
@property (nonatomic, strong) IBOutlet UITableView * tbView; (你要下拉更新的TableView)
然後在YourViewController.m中 viewDidLoad中加入:
self.refreshControl = [[UIRefreshControl alloc] init];
[self.refreshControl addTarget:self action:@selector(refresh)
forControlEvents:UIControlEventValueChanged];
[self.tbView addSubview:self.refreshControl]; //把RefreshControl加到TableView中
因為是用Selector的方式呼叫函式, 所以記得要寫一個refresh喔
-(void) refresh{
//你下拉更新之後要做的事.
}
大功造成
DONE!
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言