在我的UIViewController中,我有一个UITableView作为子视图。我使用以下代码添加了我的UIRefreshControl:
// enable "pull to refresh"
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull To Refresh!" attributes:@{NSForegroundColorAttributeName : [UIColor whiteColor], NSFontAttributeName : [UIFont systemFontOfSize:17]}];
[refreshControl addTarget:self action:@selector(fetchArticles) forControlEvents:UIControlEventValueChanged];
refreshControl.backgroundColor = [UIColor colorWithRed:0.0f/255.0f green:102.0f/255.0f blue:153.0f/255.0f alpha:1.0];
refreshControl.tintColor = [UIColor whiteColor];
self.refreshControl = refreshControl;
[self.tableView addSubview:self.refreshControl];我的应用程序中有另一个使用UITableViewController的屏幕,它的UIRefreshControl与我为UITableView添加的屏幕有很大的不同。
单独的UIRefreshControl在拖动时要慢一些,我通常需要拖得更远才能开始刷新。
在我的另一个屏幕上,用于我的UIRefreshControl的UITableViewController在拖动时会更快,而且我不需要拖到现在为止才能让它开始刷新。
我更喜欢UITableViewController's UIRefreshControl的更流畅的行为,那么如何使UIRefreshControl的UIRefreshControl更像属于UITableViewController的默认行为呢?
这个是可能的吗?还是使用UIContainerView和UITableViewController是我唯一的选择?
发布于 2016-05-16 16:41:31
UIRefreshControl的设计目的是与UITableViewController合作;在苹果的网站上,它说:
由于刷新控件是专门为表视图控制器管理的表视图中使用而设计的,因此在不同的上下文中使用它可能会导致未定义的行为。
尽管如此,人们在没有UITableViewController:UIRefreshControl without UITableViewController的情况下是成功的。使用风险自负。
https://stackoverflow.com/questions/37217863
复制相似问题