ada*_*dam 6 iphone uitableview uisearchbar
我有一个UITableView,顶部有一个UISearchBar.
我还使用Section Index委托在右侧显示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];
Run Code Online (Sandbox Code Playgroud)
我的问题是,有没有人看到过这种行为?有没有办法在RHS上重绘部分索引([[self tableView] reloadData]
不做诀窍)
太感谢了!
当搜索完全激活时,您应该禁用索引的绘制。只需在委托中返回 nil 即可,如下所示:
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView { if ([self.searchDisplayController isActive]) 返回 nil; ... }
归档时间: |
|
查看次数: |
6400 次 |
最近记录: |