Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-Layout Constraints showing unexpected behavior #359

Open
cre8ivepark opened this issue Feb 23, 2016 · 0 comments
Open

Auto-Layout Constraints showing unexpected behavior #359

cre8ivepark opened this issue Feb 23, 2016 · 0 comments

Comments

@cre8ivepark
Copy link

cre8ivepark commented Feb 23, 2016

I am experiencing unexpected behavior of Auto-Layout Constraints on several places. All of them are added programmatically. Works well on Xcode but shows weird behavior on VS.
Adding some screen shots of Xcode and VS. Please take a look at the spacings marked with red block.

Example of Auto-Layout Constraints for UITableView & UIScrollView:

[tvList setTranslatesAutoresizingMaskIntoConstraints : NO];
[self.view addConstraints : [NSLayoutConstraint constraintsWithVisualFormat : @"H:|-0-[tvList(250)]" options : NSLayoutFormatDirectionLeadingToTrailing metrics : nil views : NSDictionaryOfVariableBindings(tvList)]];
[self.view addConstraints : [NSLayoutConstraint constraintsWithVisualFormat : @"V:|-0-[tvList]-0-|" options : NSLayoutFormatDirectionLeadingToTrailing metrics : nil views : NSDictionaryOfVariableBindings(tvList)]];

[svContent setTranslatesAutoresizingMaskIntoConstraints : NO];
[self.view addConstraints : [NSLayoutConstraint constraintsWithVisualFormat : @"H:[tvList(250)]-0-[svContent]-0-|" options : NSLayoutFormatDirectionLeadingToTrailing metrics : nil views : NSDictionaryOfVariableBindings(tvList, svContent)]];
[self.view addConstraints : [NSLayoutConstraint constraintsWithVisualFormat : @"V:|-0-[svContent]-0-|" options : NSLayoutFormatDirectionLeadingToTrailing metrics : nil views : NSDictionaryOfVariableBindings(svContent)]];

typographyinsight_iw_autolayout1a

Below example uses Auto-Layout Constraints inside the UICollectionViewCell, for the UILabel element:

    label = [[UILabel alloc] initWithFrame:CGRectMake(0,0,150,250)];
    label.textAlignment = UITextAlignmentCenter;
    [self.contentView addSubview:label];
    label.font = [UIFont systemFontOfSize:120];
    label.clipsToBounds = NO;
    label.adjustsFontSizeToFitWidth = YES;
    self.contentView.clipsToBounds = NO;

    [self.contentView setBackgroundColor:[UIColor lightGrayColor]];
    [label setBackgroundColor:[UIColor yellowColor]];
    [label setTranslatesAutoresizingMaskIntoConstraints : NO];
    [self.contentView addConstraints : [NSLayoutConstraint constraintsWithVisualFormat : @"H:|-[label]-|" options : NO metrics : nil views : NSDictionaryOfVariableBindings(label)]];
    [self.contentView addConstraints : [NSLayoutConstraint constraintsWithVisualFormat : @"V:|-[label]-|" options : NO metrics : nil views : NSDictionaryOfVariableBindings(label)]];

typographyinsight_iw_autolayout2

@tadam-msft tadam-msft added this to the Backlog milestone Mar 21, 2017
@tadam-msft tadam-msft modified the milestones: 1704, Backlog Mar 30, 2017
@jaredhms jaredhms assigned rajsesh and unassigned jaredhms May 11, 2017
@rajsesh rajsesh modified the milestones: 1704, 1706 Jun 1, 2017
@rajsesh rajsesh modified the milestones: Backlog, 1706 Jun 21, 2017
@rajsesh rajsesh assigned yiyang-msft and unassigned rajsesh Jun 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants