Xcode UITableView问题-更新表值

Xcode UITableView问题-更新表值,xcode,ios,uitableview,Xcode,Ios,Uitableview,我是个新手。我已经为UITable编写了一些代码,但是在将值添加到数组后,我无法更新表值。我使用的是tableview子类。代码如下。检查最后一个函数。现在我如何更新我的表值 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { //#warning Potentially incomplete method implementation. // Return the number of sections.

我是个新手。我已经为
UITable
编写了一些代码,但是在将值添加到数组后,我无法更新表值。我使用的是
tableview
子类。代码如下。检查最后一个函数。现在我如何更新我的表值

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
//#warning Potentially incomplete method implementation.
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
//#warning Incomplete method implementation.
    // Return the number of rows in the section.
    return [_phones count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    }

       HLPFoundPhones *p = (HLPFoundPhones *)[_phones objectAtIndex:indexPath.row];
       NSString *subtitle = [NSString stringWithFormat:@"Found (%1.2f,%1.2f) on %@" ,[p loc].x, [p loc].y , [p foundDate]];
       cell.textLabel.text = [p name];
       cell.detailTextLabel.text = subtitle;

       return cell;
}


- (void)insertNewObject
{
    HLPPhonesAdd *view = [[HLPPhonesAdd alloc]initWithNibName:@"HLPPhonesAdd" bundle:nil];
    [self.navigationController pushViewController:view animated:YES];
    [view release];

   }
- (void)updateTable:(CGPoint)loc name:(NSString *)_name{
    HLPFoundPhones *a = [[HLPFoundPhones alloc]initWithLoc:loc name:_name];
    [_phones addObject:a];
    [phones reloadData];

}
召唤

在updateTable函数中

- (void)updateTable:(CGPoint)loc name:(NSString *)_name{
    HLPFoundPhones *a = [[HLPFoundPhones alloc]initWithLoc:loc name:_name];
    [_phones addObject:a];

   //give your tableView object instead of yourTableView
   [yourTableView reloadData];

}

检查_phonecount的值并在函数中使用

- (void)updateTable:(CGPoint)loc name:(NSString *)_name
{
    HLPFoundPhones *a = [[HLPFoundPhones alloc]initWithLoc:loc name:_name];
    [_phones addObject:a];
    [table_name reloaddata];
}

确认已分配阵列
\u电话

如果在线程内调用
[tableview reloadData]
,则会出现问题。
因此,请确认是否从主线程调用了重新加载的数据。

首先,所有单元格的单元格标识符看起来都是相同的,这可能会混淆iOS需要退出队列的单元格。因此,保持您的手机标识符的唯一性,如下所示:

NSString *cellIdentifier = [NSString stringWithFormat:@"Cell-%d", indexPath.row];
然后,在首次显示表视图后,更新数据源并调用:

[tableView reloadData];

不走运。。任何其他建议。。重载数据是否适用于其他预定义函数。。?我的文件中只有3个表函数。。。如上所述。。没有其他功能。。那么我需要另一个函数吗?哈迪,做这些事情..首先检查调用reloadData后是否调用了CellForRowatinex(在那里放置一个断点并进行检查)…第二个在updateTable函数中,检查tableView对象是否有有效地址(尝试记录对象..)不,它不会回调。。顺便说一句,我正在使用完整视图来显示表,所以起初我的表视图没有名称,它是通用的,我现在根据你的建议命名它,它也不调用表视图..我能回忆一下表函数吗。。。。?通过此函数更新行的方法还有其他方法…Hadi..当您编写/编辑问题时,在向问题添加所有代码后,选择这些代码并单击编辑对话框顶部的{}按钮,这将格式化代码。。
[tableView reloadData];