Question

I am using UITableVeiw with static cells in iOS7. The table view looked like this before I converted my storyboard to use autolayouts.

enter image description here

I am using the "background view" property and the "selectedBackgroundView" property of the tableviewcell to set backgrounds like so:

enter image description here

After enabling auto-layout though in the storyboard, the layout goes bonkers and this is what I am left with:

enter image description here

I don't have any auto-layout issues that are presented to me. Just that I am not seeing the foreground and background anymore with auto-Layouts.

Any help?

Was it helpful?

Solution

Seems like the auto-layout was creating problems for me. I added the backgroundView and selectedBackgroundView programmatically and it works.

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    UIView *selectedView =[UIView new];
    selectedView.backgroundColor=[UIColor colorWithRed:0.604 green:0.812 blue:0.059 alpha:1.000];
    cell.selectedBackgroundView = selectedView;
    UIView *defaultView =[UIView new];
    defaultView.backgroundColor=[UIColor colorWithRed:0.396 green:0.404 blue:0.404 alpha:1.000];
    cell.backgroundView = defaultView;
}

OTHER TIPS

I think it can be fixed in Storyboard but... the "solution" is totally stupid :D. If add width and height constraint to selectedBackgroundView it will works. This solution isn't good for me, but seems like it works :)

P.S. The way with adding selectedBackgroundView programmatically is work for me too.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top