Label in UITableViewCell not changing the first time its loaded

烂漫一生 提交于 2019-12-13 04:49:22

问题


Ok so i have a UITableView that fetches some data from a web server and displays the data.

Depending on a text of a label the label will need to move a bit to the left if the if statement is true.

     if ([gameInfoObject.GameTime  isEqual: @"FT"] | ([gameInfoObject.GameTime rangeOfString:@":"].location != NSNotFound)) {   // CHeck to see if its FT or string contains ":" then hide liveB

        cell.liveButton.hidden = YES;   //Hide the image cause gameTimeLable will take its position

        CGRect frame = cell.gameTimeLabel.frame;
        frame.origin.x= 27;                         // move the label to the left since no image will be present
        cell.gameTimeLabel.frame= frame;

}

I have a timer that runs:

 [self.tableview reloadData];

The problems is when the application starts the labels are not correctly positioned. But after 5 seconds when the timer activate reloadData it changes to its accurate position.

How can i make it so the labels will change the first time? Thnx..

----------------------------------------------------------------------------Edit 1

- (void) retrieveData{

GetData *getDataObject = [[GetData alloc] init];  // fixa detta sen

[getDataObject getAllGamesWithCompletionHandler:^(id responseObject, NSError *error) {

    if (!responseObject) {
        NSLog(@"failed: %@", error);
        return;
    }

    gamesInfoArray = (NSMutableArray *)responseObject;
    [self.tableView reloadData]; //first time it gets called here
}];

}

来源:https://stackoverflow.com/questions/27307814/label-in-uitableviewcell-not-changing-the-first-time-its-loaded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!