问题
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