测试已测试 | ✗ |
Lang语言 | Obj-CObjective C |
许可 | MIT |
Released上次发布 | 2014年12月 |
由 Ben Oztalay 维护。
用于 iOS 的下拉刷新控件,可以玩 Pong 游戏。
它在 CocoaPods 上!在 Podfile 中添加 pod 'BOZPongRefreshControl'
。
或者,只需将 BOZPongRefreshControl.h
和 BOZPongRefreshControl.m
文件放在您项目的任何位置。
将其附加到 UITableView
或 UIScrollView
如下所示
- (void)viewDidLoad
{
[super viewDidLoad];
/* NOTE: Do NOT attach the refresh control in viewDidLoad!
* If you do this here, it'll act very funny if you have
* a navigation bar or other such similar thing that iOS
* automatically offsets content for. You have to wait for
* the subviews to get laid out first so the refresh
* control knows how big that offset is!
*/
}
- (void)viewDidLayoutSubviews
{
self.pongRefreshControl = [BOZPongRefreshControl attachToTableView:self.tableView
withRefreshTarget:self
andRefreshAction:@selector(refreshTriggered)];
}
然后,在您的 UIViewController
中实现 UIScrollViewDelegate
,如果尚未实现,然后将调用传递给刷新控件
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
[self.pongRefreshControl scrollViewDidScroll];
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
[self.pongRefreshControl scrollViewDidEndDragging];
}
最后,确保您已经实现了您之前传递给它的 refreshAction
以监听刷新触发器
- (void)refreshTriggered
{
//Go and load some data
//Finshed loading the data, reset the refresh control
[self.pongRefreshControl finishedLoading];
}
有关更多详细信息,请查看演示应用的代码。它有在 UIScrollView
上以及在 UITableViewController
外部使用刷新控件的示例。
foregroundColor
属性设置前景色backgroundColor
属性设置背景色totalHorizontalTravelTimeForBall
属性来调整其播放速度UIScrollView
内容冲突,该内容位于 y = 0.0f
以上