UIRefreshControl incorrect title offset during first run and sometimes title missing

前端 未结 8 958
自闭症患者
自闭症患者 2020-12-04 15:46

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 t

8条回答
  •  执笔经年
    2020-12-04 16:15

    The solution for me was to set a text in viewDidAppear, no need to call

    beginRefreshing or endRefreshing on the mainQueue

    -(void)viewDidAppear:(BOOL)animated
    {
        [super viewDidAppear:animated];
    
        NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
        [formatter setDateFormat:@"d MMM, HH:mm"];
        NSString *lastUpdated = [NSString stringWithFormat:NSLocalizedString(@"refresh_last_updated", nil),[formatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:[[[DatabaseController sharedInstance] getCurrentSettings].lastTimeStamp doubleValue]]]];
        UIFont *font = [UIFont fontWithName:FONT_LATO_LIGHT size:12.0f];
        NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:lastUpdated attributes:@{NSFontAttributeName:font}];
    
        _refreshControl.attributedTitle = attrString;
    }
    

提交回复
热议问题