我在單元格中有一個標籤,我想用我解析的JSON數組中的數據進行更新。問題是獲取數據後標籤是空白的,並且只會在上下滾動tableview後纔會顯示。我試圖強制重新加載視圖[self.view setNeedsDisplay];
,它仍然無法正常工作。我如何解決這個問題?單元格中的UILabel僅在滾動上下後顯示
下面是一些意見的代碼片段在裏面:
@implementation outletView
@synthesize outletInfo;
- (void)viewDidLoad
{
[super viewDidLoad];
...
// Do any additional setup after loading the view.
[[AFHTTPRequestOperationManager manager] GET:[SERVER_URL stringByAppendingString:@"api/points"] parameters:[NSDictionary dictionaryWithObjectsAndKeys:[[NSUserDefaults standardUserDefaults] objectForKey:@"authToken"],@"auth_token",nil] success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSString *outletID = [[outletInfo valueForKeyPath:@"preference"] objectForKey:@"outlet_id"];
NSArray *outletArray = (NSArray*)responseObject;
NSLog(@"array: %@", outletArray);
for(NSDictionary *diction in outletArray) {
NSString *dictionID = [diction objectForKey:@"outlet_id"];
if ([dictionID isEqualToString:outletID]) {
pointOutlet = [diction objectForKey:@"total"];
}
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error : %@",[error description]);
}];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = indexPath.section==0 ? @"outletViewCell" : @"categoryCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Here is the cell
if(indexPath.section==0){
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
[(UIImageView *)[cell viewWithTag:1] sd_setImageWithURL:[NSURL URLWithString:outletInfo[@"backgroundImageUrl"]] placeholderImage:nil];
[(UIImageView *)[cell viewWithTag:2] sd_setImageWithURL:[NSURL URLWithString:outletInfo[@"logoUrl"]] placeholderImage:nil];
[(UILabel *)[cell viewWithTag:3] setText:outletInfo[@"name"]];
[(UILabel *)[cell viewWithTag:4] setText:outletInfo[@"address"]];
//Here is the UILabel that I want to update
[(UILabel *)[cell viewWithTag:6] setText:pointOutlet];
} else {
...
}
return cell;
}
@end
從TableView中 – Rajesh 2014-09-23 05:03:48
的所有者重新加載表嘗試重新加載烏爾的tableview [self.tableView ReloadData]; – sanjeet 2014-09-23 05:08:20