6

上部に UISearchBar がある UITableView があります。

また、セクション インデックス デリゲートを使用して、右側に ABC...XYZ を表示します。

検索ボックスをクリックすると問題が発生し、キーボードが下から出てきて、セクション インデックスが押しつぶされて A D ...*Z のみが表示されます。検索を閉じてキーボードが消えると、インデックスはこのままになります。スクロールするまで「押しつぶされた」状態。

    // animate the searchbar
[UIView beginAnimations:nil context:NULL];
CGRect tempRect = [[self searchBar] frame];
tempRect.size.width = 320-kMarginRight;
[[self searchBar] setFrame:tempRect];
[UIView commitAnimations];  

    // animate the search index back into view
for (UIView *view in [[self tableView] subviews]) {
    if ([view respondsToSelector:@selector(moveIndexIn)]) {
        MovableTableViewIndex *index = (MovableTableViewIndex*)view;
        [index moveIndexIn];
    }
}   

    // try a whole load of stuff to try and get the section indexes to draw again properly
    // none of which work!  

[searchBar setText:@""];
[searchBar resignFirstResponder];

letUserSelectRow = YES;
searching = NO;
[[self navigationItem] setRightBarButtonItem:nil];
[[self tableView] setScrollEnabled:YES];        
[[self tableView] reloadData];
[[self tableView] flashScrollIndicators];
[[self tableView] sizeToFit];
[[self tableView] zoomScale];       
[[self tableView] reloadSectionIndexTitles];

私の質問は、誰かがこの動作を見たことがありますか? RHS でセクション インデックスを再描画する方法はありますか ([[self tableView] reloadData]トリックは行いません)。

どうもありがとう!

4

3 に答える 3

4

検索が完全にアクティブ化されている場合は、インデックスの描画を無効にする必要があります。次のように、デリゲートでnilを返すだけです。

-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
  if([self.searchDisplayController isActive])return nil;

  ..。
}
于 2009-10-02T23:40:23.547 に答える
2

あなたは使用してみることができます

- (void)flashScrollIndicators

スクロールバーを更新し、できればセクション インデックスも更新しますか?

于 2009-05-12T08:19:22.213 に答える
0

それはうまくいきます!!!

[searchBar setContentInset:UIEdgeInsetsMake(5, 0, 5, 35)];

于 2010-05-05T18:50:26.647 に答える