我的UItableview
存在问题,当我每次查看表时使用viewWillAppear
检索更新的数据时,这会让我感到异常。
任何人都可以帮我了解如何刷新viewWillAppear
中的tableview,以便在调用CellforrowAtindexPath
之前更新它吗?
以下是viewWillAppear
的代码:
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:YES];
[self.tableView reloadData];//table was filled in viewDidLoad.
}
这是CellforrowAtindexPath` :(例外是在mainArray上,这意味着通过viewWillAppear和调用单元更新表时存在冲突):
//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;
}
答案 0 :(得分:0)
return self.mainArray.count; }
如果count为0,表视图将不会调用其他函数。