How can I add a static background behind a UITableView programmatically?

I have a TableViewController and would like to have a static image as a background that doesn't scroll forward.

The way everyone recommends using

[UIColor colorWithPatternImage:[UIImage imageNamed:@"backgroundPattern.png"]] 

doesn't work how it will be

1.) move forward and 2.) place the background pattern in each cell

I know how to do this in the XIB file (namely, adding another layer under the TableView), but how to do it programmatically from the TableViewController?

+4
source share
1 answer
 [myTblViewController.view insertSubview:myImageView belowSubview:myTblViewController.tableView]; 

That should work.

If it turns out that tableView not a direct view of the main view of the table view controller, you can try:

 [[myTblViewController.tableView superview] insertSubview:myImageView belowSubview:myTblViewController.tableView]; //Edited superview should be all lower case 
+4
source

All Articles