【问题标题】:Display a custom background picture in UISearchResultsTableView in iOS在 iOS 的 ISearchResult TableView 中显示自定义背景图片
【发布时间】:2012-07-25 03:06:39
【问题描述】:

目前我有这段代码将 TableView 中的默认背景更改为自定义图片,但是当用户在 UISearchBar 中进行搜索时,搜索结果 TableView 是纯白色背景。我在哪里/如何将其更改为与我的常规非搜索 TableView 相同?

    - (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;
}

【问题讨论】:

    标签: uitableview ios4 uisearchdisplaycontroller ios5 uisearchresultscontroller


    【解决方案1】:

    您应该可以通过 searchDisplay Controller 访问 searchResults TableView:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多