在我的UIViewController
中,我有一個UITableView
作爲子視圖之一。添加我UIRefreshControl
用下面的代碼:iOS - UITableView的UIRefreshControl與UITableViewController的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
一個更加不同。
單獨的UITableView
的UIRefreshControl
在拖動時比較慢,我通常必須拖動FARTHER才能讓它開始刷新。
在我的其他屏幕上,我的UITableViewController
的UIRefreshControl
在拖動時速度更快,而且我不必拖動到目前爲止就可以開始刷新。
我喜歡UITableViewController
的UIRefreshControl
的平滑行爲,讓我怎麼得到我的UIRefreshControl
我UITableView
的行爲更像是屬於UITableViewController
默認的?
這可能嗎?或者正在使用UIContainerView
並使用UITableViewController
我唯一的選擇?
感謝您的鏈接!我對使用hacky的'UITableViewController'實例解決方案有點猶豫,但它工作完美! – Rafi