Objective c UIRefreshControl文本覆盖在刷新指示器上

Objective c UIRefreshControl文本覆盖在刷新指示器上,objective-c,overlay,ios7,uirefreshcontrol,Objective C,Overlay,Ios7,Uirefreshcontrol,我从使用iOS7SDK在XCode 5下编程开始。当我使用UIRefreshControl和'attributedText'创建UITableViewController时,我将文本覆盖在UIRefreshControl图形(循环进度动画)的顶部 但当我向下拉并松开手指时,文本跳转到其正常位置。为什么会这样 UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init]; [refreshControl add

我从使用iOS7SDK在XCode 5下编程开始。当我使用
UIRefreshControl
和'attributedText'创建
UITableViewController
时,我将文本覆盖在
UIRefreshControl
图形(循环进度动画)的顶部

但当我向下拉并松开手指时,文本跳转到其正常位置。为什么会这样

    UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
    [refreshControl addTarget:self action:@selector(updateDeviceList) forControlEvents:UIControlEventValueChanged];
    refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"Update Devices States"];

    self.refreshControl = refreshControl;
向下拉到底之前:

ui刷新控制之后
释放:


将代码更改为以下内容

self.refreshControl = [UIRefreshControl new];
[self.refreshControl addTarget:self action:@selector(updateDeviceList) forControlEvents:UIControlEventValueChanged];
self.refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"Update Devices States"];

self.refreshControl = refreshControl;
这将解决您的问题

请尝试此方法

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
    refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull to Refresh"];
    [refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];
    self.refreshControl = refreshControl;

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

}

设置标题后调用
layoutifneed

self.refreshControl = [[UIRefreshControl alloc] init];
[self.refreshControl addTarget:self action:@selector(updateDeviceList) forControlEvents:UIControlEventValueChanged];
self.refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"Update Devices States"];
[self.refreshControl layoutIfNeeded];

在这里查看我的答案:另外,如果您通过interface builder添加了刷新控件,那么只需在类中公开现有控件,然后使用dispatch_async,如此答案所示。这将允许您在IB中设置变量,并减少代码的工作量。假设苹果的代码中有一个bug,因为我无法想象他们想要这个解决方案。苹果还没有解决这个问题!谢谢你的小“黑客”;)