2011-04-08 46 views

回答

2

這是非常棘手的。 _dimmingView對於searchDisplayController是私有的,它高於所有子視圖。你可以做的是與您的自定義視圖每次出現([搜索字符串長度] == 0和DidBeginSearch)

(tempView的框架設置的UISearchBar放在桌子的tableViewHeader)

- (void)viewDidLoad { 
    tempView = [[UIView alloc] initWith...]; 
    // tempView setup 
    ... 
} 

- (void)searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller { 
    [tempView setFrame:CGRectMake(0, self.searchDisplayController.searchBar.frame.size.height, 320, self.searchDisplayController.searchResultsTableView.frame.size.height)]; 
    [self.searchDisplayController.searchContentsController.view addSubview:tempView]; 
    ... 
} 

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString 
{ 
    if ([searchString length] == 0) 
     [self.searchDisplayController.searchContentsController.view addSubview:tempView]; 
    else 
     [tempView removeFromSuperview]; 
    ... 
} 

- (void)searchDisplayControllerDidEndSearch:(UISearchDisplayController *)controller { 
    if (tempView && tempView.superview) 
     [tempView removeFromSuperview]; 
    ... 
} 

Notes時覆蓋它:我嘗試在DidBeginSearch上創建一個新實例,並在DidEndSearch上發佈它,並且它僅適用於第一次調用!奇怪...

希望這會有所幫助

相關問題