iOS 7 UIRefreshControl tintColor不适用于beginRefreshing [英] iOS 7 UIRefreshControl tintColor not working for beginRefreshing

查看:122
本文介绍了iOS 7 UIRefreshControl tintColor不适用于beginRefreshing的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的UIRefreshControl上设置tintColor(在iOS 7上构建)。
我在storyboard中为tableViewController启用了刷新,然后在我的ViewController viewDidLoad 方法中我执行了以下操作:

  [self.refreshControl setTintColor:[UIColor redColor]]; 

所以现在,当我拉动刷新时,刷新控件的颜色确实是红色的:





我希望我的视图在出现时自动更新,所以我做了:

   - (void)viewDidAppear: (BOOL)动画{
[self.refreshControl beginRefreshing];
}

根据



非常感谢!

解决方案

嘿,他们偶然发现了这个问题。



有趣的是,我通过首先设置contentOffset然后调用beginRefreshing来修复我的代码

  if(self .tableView.contentOffset.y == 0){
self.tableView.contentOffset = CGPointMake(0,-self.refreshControl.frame.size.height);
[self.refreshControl beginRefreshing];
}

您可能想要为此过程制作动画:

  [UIView animateWithDuration:0.25 delay:0选项:UIViewAnimationOptionBeginFromCurrentState动画:^(void){
self.tableView.contentOffset = CGPointMake(0,-self) .refreshControl.frame.size.height);
}完成:^(BOOL完成){
[self.refreshControl beginRefreshing];
}];

希望这可以帮到你。



W


I'm trying to set a tintColor on my UIRefreshControl (building on iOS 7). I enabled refreshing for the tableViewController in storyboard, then in my ViewController viewDidLoad method i did the following:

[self.refreshControl setTintColor:[UIColor redColor]];

So now, when I pull to refresh, the color of the refresh control is red indeed:

I want my view to update automatically when it appears, so I did:

- (void)viewDidAppear:(BOOL)animated{
    [self.refreshControl beginRefreshing];
}

It didn't show the spinning wheel, according to https://stackoverflow.com/a/16250679/1809736, I added

[self.tableView setContentOffset:CGPointMake(0, -self.refreshControl.frame.size.height) animated:NO];

to force show it. It shows it, but now it is back to default color:

If I try manually to pull to refresh afterwards, it is red.

I tried building it on iOS6 and it works as it should, so is that an iOS7 bug?

P.S.: it is not a problem with the simulator, I tried building it on device, same bug.

P.P.S: I built an example project, can you tell me if you have the same bug or if there is a problem in my code? Here is the link: http://d.pr/f/pGrV

Thanks a lot !

解决方案

Hey just stumbled into this exact issue.

Interestingly I fixed my code by setting the contentOffset first then calling beginRefreshing

if(self.tableView.contentOffset.y == 0){
    self.tableView.contentOffset = CGPointMake(0, -self.refreshControl.frame.size.height);
    [self.refreshControl beginRefreshing];
}

You may want to animate this process:

[UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^(void){
    self.tableView.contentOffset = CGPointMake(0, -self.refreshControl.frame.size.height);
} completion:^(BOOL finished) {
    [self.refreshControl beginRefreshing];
}];

Hope this helps you.

W

这篇关于iOS 7 UIRefreshControl tintColor不适用于beginRefreshing的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆