uisearchbarからステーションを選択できる設定画面を作成しています。ステーションの最初の文字をヘッダーとして、すべてのステーションが最初の文字で分類された、セクション化されたテーブルビューがあります。ここまでは順調ですね。セクションごとにステーションを備えた2つのNSMutableArrayがあります。1つはフィルター処理されていない配列(フィルター処理されていない場合に使用します)で、もう1つは何かを検索している場合です。(私は述語を介してこれを行います)。キーボードのキーを押すたびに、[self.tableViewreloadData]を実行します。これは機能しますが、スクロールビューが長すぎます。したがって、選択した配列に実際に含まれる結果の数を超えてスクロールできます。存在しないオブジェクトを取得しようとしているため、これによりクラッシュが発生します。
それで、テーブルビューは配列を正しくカウントしていないように見えますか?この問題に精通している人はいますか?
ここにいくつかのコードがあります:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    if (self.searching) {
        return [self.tableFilterd count];
    } else {
        return [self.tableData count];
    }
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSLog(@"Rows for section");
    // Return the number of rows in the section.
    if (self.searching) {
        NSLog(@"Editing section: %i, count %i", section, [[self.tableFilterd objectAtIndex:section] count]);
        return [[self.tableFilterd objectAtIndex:section] count];
    } else {
        NSLog(@"Not editing");
        return [[self.tableData objectAtIndex:section] count];
    }
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    SettingsHeaderCell *cell = [[[SettingsHeaderCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"HeaderCell"] autorelease];
    cell.labelLetter.text = [[self.tableLetters objectAtIndex:section] capitalizedString];
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 40;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 52;
}
- (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    SettingsCell *cell = [theTableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[SettingsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    if (self.searching) {
        StationObject *object = (StationObject *)[[self.tableFilterd objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
        [cell setStationObject:object];
    } else {
        StationObject *object = (StationObject *)[[self.tableData objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
        [cell setStationObject:object];
    }
    return cell;
}