UITableView를 채우는 데 사용하는 웹 서비스에서받은 배열 객체가 있습니다. 내가 webservice에서 새 배열을 가져오고 테이블을 채우고 다음이 배열에서 새 개체를 사용하려면 tableView 다시로드 내 배열을 재정의하는 메서드를 구현하는 중이 야. 이 일해야하는 방법입니다 :Reload UITableView 데이터가 제대로 작동하지 않습니다.
WSCaller *caller = [[WSCaller alloc]init];
arrayFromWS = [caller getArray];
[self.table reloadData];
을하고 작동하지 않습니다. 어떤 아이디어?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = @"productsCellIdentifier";
ProductsCell *cell = nil;
cell = (ProductsCell *)[self.table dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell)
{
NSArray *topLevelObjects = [[NSBundle mainBundle]loadNibNamed:@"ProductsCell" owner:nil options:nil];
for (id currentObject in topLevelObjects)
{
if ([currentObject isKindOfClass:[ProductsCell class]])
{
cell = (ProductsCell *)currentObject;
break;
}
}
}
if (productsMutableArray)
{
cell.backgroundColor = [UIColor whiteColor];
cell.productName.text = [[self.productsMutableArray objectAtIndex:indexPath.row]objectForKey:@"name"];
}
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [productsMutableArray count];
}
정확히 어떤 나던 작업 –
변경'self.table' :
이 문제를 해결하려면, 나는 (당신의 productsMutableArray이/보유 재산 강력한이라고 가정처럼 뭔가를 위해 위의 코드를 변경하는 것이 좋습니다 것 'self.tableView'. – gtmtg
배열의 새 객체로'tableView'를 업데이트하지 않습니다. –