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

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

问题描述

第一次启动 UIRefreshControl 时文本偏移错误...后来有时刷新文本根本不显示,只有多刺可见

我不认为我在 iOS6 上遇到过这个问题...可能与 iOS7 相关

位于作为子项添加到 VC 的 UITableViewController 中,该控制器驻留在模态呈现的 UINavigationController 中

- (void)viewDidLoad {[超级viewDidLoad];[self setRefreshControlText:@"获取注册数据"];[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 作为子视图添加到包装视图控制器似乎首先为我修复了它,尽管自 iOS 7 GM 以来该错误又回来了.

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

<块引用>

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

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

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

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];

}

解决方案

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.

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天全站免登陆