UITableView 仅在我上下滚动时显示来自 JSON 数组的数据。当我加载表格 View 时,它显示单元格,但它们是空白的,当我上下滚动时,它开始显示数据。
如何在不滚动的情况下显示带有数据的单元格?
- (void)requestFinishedASIHTTPRequest *)request
{
if (request.responseStatusCode == 400) {
NSLog( @"Code already used");
} else if (request.responseStatusCode == 403) {
NSLog( @"Code already used");
} else if (request.responseStatusCode == 200) {
NSLog(@"%@",[request responseString]);
NSString *response = [request responseString];
const char *convert = [response UTF8String];
NSString *responseString = [NSString stringWithUTF8String:convert];
responseArray = [responseString JSONValue];
Nrows = [responseArray count];
}
}
- (UITableViewCell *)tableViewUITableView *)tableView cellForRowAtIndexPathNSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
NSDictionary *dict = [responseArray objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [dict objectForKey"allfeeds"];
cell.textLabel.adjustsFontSizeToFitWidth = YES;
cell.textLabel.font = [UIFont systemFontOfSize:12];
cell.textLabel.minimumFontSize = 10;
cell.textLabel.numberOfLines = 4;
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.textLabel.text = [dict objectForKey"allfeeds2"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
Best Answer-推荐答案 strong>
完成请求并设置数组后,请确保调用 [self.tableView reloadData];
出于性能和动画目的, TableView 不会在源更改时重新加载其数据。
关于iphone - UITableView 仅在我上下滚动时显示来自 JSON 的数据,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/9808752/
|