I am drawing a custom UIView in every table view cell like so:
_checkboxView = [[[UIView alloc] initWithFrame:CGRectMake(cell.frame.size.width - 28.5, cell.frame.size.height - 33.5, 25, 25)] autorelease];
_checkboxView.backgroundColor = [UIColor clearColor];
_checkboxView.layer.borderWidth = 4.0f;
_checkboxView.layer.borderColor = [[UIColor blackColor] CGColor];
_checkboxView.layer.cornerRadius = 4.0f;
[cell addSubview:_checkboxView];
[cell bringSubviewToFront:_checkboxView];
This works perfectly, but when the phone is switched to landscape mode, the checkbox is in the wrong place, and goes near the middle of the table view cell. I need it to stay anchored to the right side of the cell using the constraints I made for portrait mode. Naturally, I would just go to the method:
-(void)viewWillLayoutSubviews
But how do I make sure that I am able to properly anchor the view for every UITableViewCell? I can't use interface builder (and thus Auto Layout) because the entire thing is built programatically. How would I get a handle of the specific cell it's looking at in this method?