2011-08-01 53 views
2

我有一個表視圖,其中部分索引啓用。所有的索引都顯示正確,但我無法讓搜索圖標實際響應。左邊的圖片顯示了在使用右側的區段索引滾動條後,表格會滾動的高度,但它應該顯示右邊的設計。任何幫助將非常感激!!UITableView部分索引不響應

Left side shows what happens when I scroll through the section index. It stops at A, but I want the search icon to result in the table view scrolling to the top

+0

我不明白你的問題,你能澄清一下嗎? – titaniumdecoy

+0

您是使用SearchDisplayController還是簡單的SearchBar?不要將SearchBar附加到你的tableView。保持它與UITableView分開。 –

+0

右側的部分索引滾動區域中的所有部分索引都與搜索圖標保持一致。如何啓用搜索圖標導致tableview滾動到頂部? –

回答

1

我一直在做定製的滾動在這種情況下,搜索欄,並返回-1從委託方法。

我的tableView:sectionForSectionIndexTitle:atIndex:是這樣的 - 不知道是否有更好的方法,雖然:

- (NSInteger)tableView:(UITableView *)tv sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index { 
    NSInteger section = -1; 
    if ([title isEqualToString:UITableViewIndexSearch]) { 
     CGRect searchBarFrame = self.searchDisplayController.searchBar.frame; 
     [tv scrollRectToVisible:searchBarFrame animated:NO]; 
    } 
    else { 
     section = whatever logic you use to determine section 
    } 
    return section; 
} 

順便說一句,這是在使用的searchDisplayController屬性。