Problem with adding an attribute called UIRefreshControl

OK, I have an application that I'm trying to work in iOS 7. There is a simple UITableViewController. I would like to add a UIRefreshControl to the table.

If I add it, without any heading, then I can tear down my table, I see that the control, it rotates, everything works fine.

But I want to add a title to the control and make it centered. So I did this:

self.refreshControl = [UIRefreshControl new];
[self.refreshControl addTarget:self action:@selector(doRefresh) forControlEvents:UIControlEventValueChanged];
NSMutableParagraphStyle* paragraphStyle = [NSMutableParagraphStyle new];
paragraphStyle.alignment = NSTextAlignmentCenter;
self.refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull to refresh" attributes:@{NSParagraphStyleAttributeName : paragraphStyle}];

This worked great in iOS6. But in ios7 I have to shoot more than 100 pixels before I see UIRefreshControl at all. In addition, after that I noticed that I could pull out the table, and he was stuck there, as if there was a large, white cage above all others.

But then again, this works as expected unless I set the Title attribute.

I add a partial picture of my gaze. You will see UIRefreshControl, an inch from top to bottom. "Unspecified" is the first cell in my table.enter image description here

+4
source share
1 answer

This works for me:

UIRefreshControl *refreshControl = [UIRefreshControl new];
refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull to refresh" attributes:@{NSParagraphStyleAttributeName : paragraphStyle}];

self.refreshControl = refreshControl;
+4
source

All Articles