Ios 更新视图中的UItableView是否会出现?

Ios 更新视图中的UItableView是否会出现?,ios,ipad,uitableview,viewwillappear,Ios,Ipad,Uitableview,Viewwillappear,我的UItableview有一个问题,即每次查看表时,当我使用view来检索更新的数据时,都会出现,这给了我一个例外 请任何人帮助我如何在视图中将出现中刷新tableview,以便在调用CellforrowAtindexPath之前更新它 以下是我的视图代码将出现: -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:YES]; [self.tableView reloadData];//table wa

我的
UItableview
有一个问题,即每次查看表时,当我使用
view来检索更新的数据时,都会出现
,这给了我一个例外

请任何人帮助我如何在
视图中将出现
中刷新tableview,以便在调用
CellforrowAtindexPath
之前更新它

以下是我的
视图代码将出现

-(void)viewWillAppear:(BOOL)animated
{

     [super viewWillAppear:YES];
     [self.tableView reloadData];//table was filled in viewDidLoad.

}
以下是CellForRowatineXpath`:(mainArray上存在异常,这意味着通过ViewWillDisplay更新表和调用单元格时存在冲突):

  • (NSInteger)表视图:(UITableView*)表视图行数节:(NSInteger)节;{
返回self.mainArray.count; }


如果count为0,表视图将不调用其他函数。

将代码放在上面
[超级视图将显示:是]是一种不好的做法。顺便说一下,
cellforrowatinexpath
总是在
reloaddata
之后调用。您遇到了什么异常?是在调用
[self.tableView reloadData]
之前填充了
self.main数组吗?@VaibhavSaran是的,我知道它不好,但我读过一次,它将在CellForRowatinexPath之前被调用?我得到一个例外,数组超出了范围index@AhmedZ.Yes是的。然而,我得到的例外是,您的
self.mainArray
必须缺少索引之外的数组。检查wny是否超出索引
cellforrowatinexpath
正在调用,则无需调用
reloaddata
!!
//Methods to retrive all selected words , thier sound and picture for the mother
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifer = @"Cell";
    UITableViewCell *cell= [ tableView dequeueReusableCellWithIdentifier:CellIdentifer];

    cell.textLabel.font = [UIFont systemFontOfSize:17.0];
    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                      reuseIdentifier:CellIdentifer];
    }
    cell.textLabel.font = [UIFont systemFontOfSize:17.0];
    UILabel *label ;

    label=(UILabel *)[cell viewWithTag:1];

    NSString *value = [[self.mainArray objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
    label.text = value;
    label.textAlignment=NSTextAlignmentRight;
    label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;

    //self.tableView.separatorColor = [UIColor blackColor];TRY TO SEPARETE BETEWEEN LINES OF TABLE
    UIButton *butt =(UIButton *)[cell viewWithTag:2];
    NSString *value2 = [[self.mainArray2 objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
    butt.restorationIdentifier= value2;
    [butt addTarget:self action:@selector(play:) forControlEvents:UIControlEventTouchUpInside];

    NSString *value3 = [[self.mainArray3 objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
    cell.imageView.image = [UIImage imageNamed:value3];
    label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;

    return cell;
}