UIRefreshControl第一次运行时标题偏移不正确,有时标题丢失 [英] UIRefreshControl incorrect title offset during first run and sometimes title missing

查看:186
本文介绍了UIRefreshControl第一次运行时标题偏移不正确,有时标题丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第一次启动UIRefreshControl时,文本偏移错误...稍后有时刷新文本根本不会显示,只是spiny是可见的

The text is offset wrong by the first launch of UIRefreshControl... later sometimes the refresh text doesn't show up at all and just the spiny is visible

我不认为我有这个问题与iOS6 ...可能与iOS7相关

I don't think i had this issue with iOS6... might be related to iOS7

在一个UITableViewController作为一个孩子添加到VC,它驻留在modal present UINavigationController

Is in a UITableViewController added as a child to a VC, which resides in a modal presented UINavigationController

- (void)viewDidLoad {

    [super viewDidLoad];

    [self setRefreshControlText:@"Getting registration data"];
    [self.refreshControl beginRefreshing];
}

- (void)setRefreshControlText:(NSString *)text {

    UIFont * font = [UIFont fontWithName:@"Helvetica-Light" size:10.0];
    NSDictionary *attributes = @{NSFontAttributeName:font, NSForegroundColorAttributeName : [UIColor blackColor]};
    self.refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:text attributes:attributes];

}

推荐答案

这绝对是一个iOS 7的错误,弄清楚究竟是什么原因造成的。它似乎与视图层次有关 - 添加我的UITableViewController作为一个子视图到一个包装器视图控制器似乎为我修复它,虽然这个bug从iOS 7通用回来了。

This is definitely an iOS 7 bug, but I haven't figured out exactly what caused it. It appears to have something to do with the view hierarchy — adding my UITableViewController as a child view to a wrapper view controller appeared to fix it for me at first, although the bug is back since iOS 7 GM.

在创建刷新视图后,将UITableViewController中添加以下代码看起来像修复了定位问题:

It looks like adding the following code to your UITableViewController after creating the refresh view fixes the positioning issue for good:


dispatch_async(dispatch_get_main_queue(), ^{
    [self.refreshControl beginRefreshing];
    [self.refreshControl endRefreshing];
});


这篇关于UIRefreshControl第一次运行时标题偏移不正确,有时标题丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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