In Xcode I have created a UITableView with Dynamic Prototypes. The first cell is composed of a button, a label, and an MKMapView.
In my ...cellForRowAtIndexPath: method I use the following code:
UITableViewCell *header = [self getNewCell:@"entity_header"];
// Send map to back (put map behind everything else)
MKMapView *MapView = (MKMapView*)[header viewWithTag:2];
[tableView sendSubviewToBack:MapView];
// Also tried using `header` here. [header sendSubviewToBack:MapView];
// Set the image of the back button.
UIButton *backButton = (UIButton*)[header viewWithTag:1];
UIImage *backBtnImg = [UIImage imageNamed:@"images/backBtn.png"];
[backButton setImage:backBtnImg forState:UIControlStateNormal];
[tableView bringSubviewToFront:backButton];
// Also tried using `header` here. [header bringSubviewToFront:backButton];
I would like to send the MKMapView behind the other components however the code above does not work as intended.
NOTE: The reason I use viewWithTag here is so that I don't have to create outlets for all of the components. (It's tricky creating outlets from inside a UITableViewCell without using more implementation files)
cellinstead oftableViewyou component has been added on Cell not tableview.. - iphonic