Display a custom background picture in UISearchResultsTableView in iOS

Currently I have this code that changes the default background in a TableView to a custom picture, but when the user does a search in the UISearchBar, the Search Results TableView is a plain white background. Where/how do I change it to be the same as my regular non-searched 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;
}

Answers


You should be able to access the searchResults TableView through the searchDisplay Controller:

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

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

Need Your Help

Animating UILabel Fade In/Out

iphone uiview core-animation uiviewanimation

I am going to end up with an array of RSS feeds, and would like a label or some such to display them at the bottom of the view. I would like to animate through each feed in the array.