1

현재 TableView의 기본 배경을 사용자 정의 그림으로 변경하는이 코드가 있지만 사용자가 UISearchBar에서 검색을 수행하면 검색 결과 TableView는 일반 흰색 배경입니다 . 어디서/어떻게 그것을 정기적으로 검색되지 않는 TableView와 동일하게 변경합니까?iOS의 UISearchResultsTableView에 사용자 정의 배경 그림 표시

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     self.title = NSLocalizedString(@"Employee List", @"Employee List"); 
     if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { 
      self.clearsSelectionOnViewWillAppear = NO; 
      self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0); 
     } 
     else { 
      { 
       UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Cloth.png"]]; 
       [tempImageView setFrame:self.tableView.frame]; 

       self.tableView.backgroundView = tempImageView; 
      } 
     } 
    } 
    return self; 
} 

답변

1

당신은 searchDisplay 컨트롤러를 통해의 SearchResult있는 TableView에 액세스 할 수 있어야합니다 :

... 
UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Cloth.png"]]; 
[tempImageView setFrame:self.tableView.frame]; 

self.tableView.backgroundView = tempImageView; 
self.searchDisplayController.searchResultsTableView.backgroundView = tempImageView; 
... 
+0

브릴리언트! 고맙습니다. – OscarTheGrouch