在我的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
的UITableView
较慢,我通常必须拖动FARTHER才能使其开始刷新。拖动时,我在其他屏幕上的
UIRefreshControl
的UITableViewController
更快,并且我不必拖动太远就可以开始刷新。我更喜欢
UITableViewController
的UIRefreshControl
的行为更平滑,那么如何使我的UIRefreshControl
的行为更像属于UITableView
的默认行为?这可能吗?还是使用
UITableViewController
并使用UIContainerView
是我唯一的选择? 最佳答案
UIRefreshControl
设计为与UITableViewController
一起使用;在苹果网站上显示:
由于刷新控件是专门为在由表视图控制器管理的表视图中使用而设计的,因此在不同的上下文中使用刷新控件可能导致未定义的行为。
话虽这么说,但没有UITableViewController
:UIRefreshControl without UITableViewController,人们就取得了成功。使用风险自负。
关于ios - iOS-UITableView的UIRefreshControl与UITableViewController的UIRefreshControl,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37217863/