首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iOS -UITableView的UIRefreshControl与UITableViewController的UIRefreshControl

iOS -UITableView的UIRefreshControl与UITableViewController的UIRefreshControl
EN

Stack Overflow用户
提问于 2016-05-13 19:24:10
回答 1查看 255关注 0票数 0

在我的UIViewController中,我有一个UITableView作为子视图。我使用以下代码添加了我的UIRefreshControl

代码语言:javascript
复制
// 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在拖动时要慢一些,我通常需要拖得更远才能开始刷新。

在我的另一个屏幕上,用于我的UIRefreshControlUITableViewController在拖动时会更快,而且我不需要拖到现在为止才能让它开始刷新。

我更喜欢UITableViewController's UIRefreshControl的更流畅的行为,那么如何使UIRefreshControlUIRefreshControl更像属于UITableViewController的默认行为呢?

这个是可能的吗?还是使用UIContainerViewUITableViewController是我唯一的选择?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-05-16 16:41:31

UIRefreshControl的设计目的是与UITableViewController合作;在苹果的网站上,它说:

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

尽管如此,人们在没有UITableViewControllerUIRefreshControl without UITableViewController的情况下是成功的。使用风险自负。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37217863

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档