UIRefreshControl 下拉刷新
2018-07-20 来源:open-open
- (void)viewDidLoad {
[super viewDidLoad];
//UIRefreshControl
//系统自带,继承自UIControl,UIControl继承自UIView
UIRefreshControl * refresh = [[UIRefreshControl alloc] init];
[self.tableView addSubview:refresh];
//设置标题
NSAttributedString * title = [[NSAttributedString alloc] initWithString:@"下拉刷新"];
refresh.attributedTitle = title;
//监听什么时候开始下拉刷新
[refresh addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];
}
//监听方法
- (void)refresh:(UIRefreshControl *)refresh
{
NSLog(@"开始刷新");
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[NSThread sleepForTimeInterval:2];
//回主线程刷新
dispatch_sync(dispatch_get_main_queue(), ^{
[refresh endRefreshing];
});
});
}
标签: isp
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
上一篇: GCD的常用方法总结
下一篇:UIDatePicker使用
最新资讯
热门推荐