0

Uitableview の問題が再び発生しました。データをリロードするたびにテーブルビューがリロードされますが、データが最初の行から開始されないようです。下の画像を参照してください。

データのリロード後に次のことを試しましたが、まだ成功しませんでした:

[self.tableView reloadData];
// this or the other one ... [self.tableView setContentOffset:CGPointZero animated:NO];
[self.tableView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:NO];

これは、viewdidloadにuitableviewを配置する方法です

self.tableView.frame = CGRectMake(450, 20, self.tableView.frame.size.width, self.tableView.frame.size.height - 20);

編集1:

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

    User *user = [users objectAtIndex:indexPath.row];
    UserTableCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if(cell == nil)
    {
        cell = [[UserTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    cell.name.text =  [NSString stringWithFormat:@"%@ %@", user.firstName, user.lastName];

    return cell;
}
4

1 に答える 1