Nitish
Nitish

Reputation: 14123

Constraints disabled in Editor -> Pin

I am trying to set constraints on UITableView using storyboard. In Editor -> Pin option, constrains are disabled.

enter image description here

Why aren't they enabled ?

Update: Gabbler's observation correctly states that tableView is the topmost view, you don't have to do the pin action on it. My purpose of setting constraints was to void leading space to tableView which comes by default when applications runs. Please check the screenshot :

enter image description here

Upvotes: 0

Views: 172

Answers (1)

gabbler
gabbler

Reputation: 13766

What you are looking for is separatorInset and layoutMargins. In viewDidLoad:

self.tableView.layoutMargins = UIEdgeInsetsZero;
self.tableView.separatorInset = UIEdgeInsetsZero;

And add this method.

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell     forRowAtIndexPath:(NSIndexPath *)indexPath{

    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}

Upvotes: 1

Related Questions