Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIRefreshControl incorrect title offset during first run and sometimes title missing

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

enter image description here

enter image description here

like image 757
Peter Lapisu Avatar asked Oct 01 '13 16:10

Peter Lapisu


2 Answers

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]; }); 
like image 99
Ben Jackson Avatar answered Oct 06 '22 16:10

Ben Jackson


calling endRefreshing under viewWillAppear did it for me:

-(void)viewWillAppear:(BOOL)animated {     [super viewWillAppear:animated];      [self.refreshControl endRefreshing]; } 

Under iOS7 with a custom UITableViewController inside a UINavigationController

like image 36
Edgar Avatar answered Oct 06 '22 16:10

Edgar