我在单元格中有一个标签,我想用我解析的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