【发布时间】:2012-06-27 14:34:55
【问题描述】:
我有一个从我的网络服务接收到的数组对象,用于填充 UITableView。我正在尝试实现一种从 web 服务获取新数组并重新定义填充表的数组然后重新加载 tableView 以使用该数组中的新对象的方法。 这是应该完成工作的方法:
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更改为self.tableView。 -
它不会用数组中的新对象更新
tableView。 -
如果我们看不到您如何填充您的表格视图,我们怎么能说,为什么您的表格没有显示所需的信息?发布 tableViewDelegate 和 tableViewDataSource 方法。并详细说明问题所在(表根本没有重新加载或只显示空表等)
-
@gtm 它仍然不起作用。 =/
-
是的,您可以在
UITableViewController中发布代码吗?正如@Morion 所说,我们现在没有足够的信息。
标签: ios uitableview reload