在我的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添加的屏幕有很大不同。

拖动时,单独的UIRefreshControlUITableView较慢,我通常必须拖动FARTHER才能使其开始刷新。

拖动时,我在其他屏幕上的UIRefreshControlUITableViewController更快,并且我不必拖动太远就可以开始刷新。

我更喜欢UITableViewControllerUIRefreshControl的行为更平滑,那么如何使我的UIRefreshControl的行为更像属于UITableView的默认行为?

这可能吗?还是使用UITableViewController并使用UIContainerView是我唯一的选择?

最佳答案

UIRefreshControl设计为与UITableViewController一起使用;在苹果网站上显示:


  由于刷新控件是专门为在由表视图控制器管理的表视图中使用而设计的,因此在不同的上下文中使用刷新控件可能导致未定义的行为。


话虽这么说,但没有UITableViewControllerUIRefreshControl without UITableViewController,人们就取得了成功。使用风险自负。

关于ios - iOS-UITableView的UIRefreshControl与UITableViewController的UIRefreshControl,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37217863/

10-12 19:16