Reputation: 4481
OK, I have an app that I'm trying to get to work in iOS 7. There is a simple UITableViewController. I would like to add a UIRefreshControl to the table.
If I add it in, without any title, then I can pull down on my table, I see the control, it spins, everything works great.
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 pull down over 100 pixels, before I see the UIRefreshControl at all. Also, after this happens, I noticed that I can pull down the table, and it sticks there, as if there's a large, white cell above all the others.
But again, this works as expected if I don't set the attributedTitle.
I'm attaching a partial picture of my view. You'll see the the UIRefreshControl, over an inch down from the top. "Unspecified" is the first cell in my table.
Upvotes: 4
Views: 1248
Reputation: 41
This works for me:
UIRefreshControl *refreshControl = [UIRefreshControl new];
refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull to refresh" attributes:@{NSParagraphStyleAttributeName : paragraphStyle}];
self.refreshControl = refreshControl;
Upvotes: 4