本文介绍了给UIRefreshControl一个顶部插图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用类似的UIRefreshControl(没有UITableViewController):

I use an UIRefreshControl like it (without an UITableViewController) :

UIRefreshControl *refreshControl = [UIRefreshControl new];
[refreshControl addTarget:self action:@selector(viewDidBeginRefreshing:) forControlEvents:UIControlEventValueChanged];
[self.table addSubview:refreshControl];

问题是刷新轮位于UINavigationController的半透明条(ios7)下方。
StackOverflow上只有几个关于此问题的主题。他们并没有为我带来任何有价值的解决方案。

Problem is the refresh wheel is positioned below the UINavigationController's translucent bar (ios7).There is only a few topic on this problem on StackOverflow. And they didn't bring any valuable solution to me.

我希望将我的UIRefreshControl的y位置降低80px例如。

What I wish is to make my UIRefreshControl's y position 80px down for example.

注意:我知道不建议在UITableViewController外部使用UIRefreshControl。所以不需要警告它。

Note : I know it's not recommended to use UIRefreshControl outside an UITableViewController. So no need to warn about it.

推荐答案

我找到了一个解决方案,非常简单,不那么干净,但却像魅力一样。

I found a solution, very simple, not so clean but works like a charm.

只需将刷新控件放在另一个设定的子视图中。

Just need to put the refresh control in another subview which is set down.

UIView *refreshView = [[UIView alloc] initWithFrame:CGRectMake(0, 80, 0, 0)];
[self.table addSubview:refreshView];

UIRefreshControl *refreshControl = [UIRefreshControl new];
[refreshControl addTarget:self action:@selector(viewDidBeginRefreshing:) forControlEvents:UIControlEventValueChanged];
[refreshView addSubview:refreshControl];

这篇关于给UIRefreshControl一个顶部插图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 12:41