-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Masonry is malfunctioning in iOS 10 while compiling with XCode 8. #382
Comments
@aquaibm are you using interface builder at all? Looks like iOS 10 has two additional constraints there for width/height unsure why but that's whats causing the error. |
No, I am not using interface builder, purely code layout,NO xib file for this class. |
@aquaibm what if you do |
@aquaibm basically something in iOS 10 runtime is adding:
Masonry was not in the past nor will ever modify non Masonry constraints so somehow you have to track down what new API(s) are necessary to stop those two constraints from being created/added. |
@robertjpayne
|
Basically the code I've posted is to make sure the cell's contentView grows as the imageView size changes later, yes ,I am using UITableView dynamic height trick, it works well before iOS 10. |
@aquaibm right so this isn't an issue with Masonry it's something to do with iOS 10, unfortunately I'm not sure what exactly is causing those two extra constraints but I would poke around with some of the API's related to auto sizing and see if that is the cause. |
Did you figure out what the issue was @aquaibm I seem to be discovering the same thing. For context, @robertjpayne.. it seems that we now have to set a "placeholder" height with UITableViewCell's that require some sort of dynamic layout based off content. UITableViewAutomaticCellDimension doesn't seem to work properly. Happy to sync and set up an example project if this helps you debug, @robertjpayne? |
@anthonygeranio nope. |
I have the same problem “It worked well before I updated to iOS 10 and Xcode 8.” - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.translatesAutoresizingMaskIntoConstraints = NO; // update xcode8 new add
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self initSubview];
}
return self;
}
- (void)initSubview{
self.titleLabel = [[UILabel alloc] init];
self.titleLabel.numberOfLines = 0;
[self.contentView addSubview:self.titleLabel];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.contentView).offset(25);
make.left.equalTo(self.contentView).offset(10);
make.right.equalTo(self.contentView).offset(-10);
}];
[self.contentView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.left.equalTo(self);
make.bottom.equalTo(self.titleLabel).offset(25);
make.width.equalTo(@(SCREEN_WIDTH));
}];
}
- (void)setTitle:(NSString *)title{
_title = title;
self.titleLabel.text = title;
} tableview layout before is OK but update xcode8 layout will be chaotic, (all data show in first cell, See only a part of the data) rows height is right,but all cell overlap in first cell. why? Can anyone help me? thanks |
@aquaibm @robertjpayne @anthonygeranio Do you have any Suggestions? |
iOS 10 is not setting the initial view constraints so if you are not super thorough, not saying you have not been :), you could easily miss some. Sent from my iPhone
|
@aquaibm |
@Panajev @robertjpayne Oh,seems like I've made a mistake,thanks. |
I have already solved! I also don't know why? do you think this is helpful to you? @aquaibm |
@kevinh Nope, your solution is not suitable for my case, which needs dynamic cell heights. Besides, are you sure there were no alerts showing in your xcode console when runing the project on your devices after replacement? |
@aquaibm yes is dynamic cell heights old code is - (CGFloat)cacheTableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath indexKey:indexKey{
CGFloat height;
UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
[cell setNeedsLayout];
[cell layoutIfNeeded];
cell.bounds = CGRectMake(0,0,self.tableView.bounds.size.width, cell.bounds.size.height);
height = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
height +=1.0f;
[self.heightCacheDic setValue:[NSNumber numberWithFloat:height] forKey:indexKey];
return height;
} updated xcode8 alert (
"<MASLayoutConstraint:0x175ebfc80 UITableViewCellContentView:0x10c251f60.width == 414>",
"<NSLayoutConstraint:0x171885550 UITableViewCellContentView:0x10c251f60.width <= 320>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x171885550 UITableViewCellContentView:0x10c251f60.width <= 320> but layout is ok after I remove [cell layoutIfNeeded]; the warning disappear |
The solution: UIImageView *imageView = [UIImageView new]; |
Found a solution to this. Thinking about writing a blog post about it. Any interest? |
@anthonygeranio I would be interested in reading it. |
Sweet gonna put something together tomorrow @beloso |
Thanks for this :)! Sent from my iPhone
|
@anthonygeranio I will be updating an app to iOS 10. I am using masonry and it would be good to know the problems and how to solve them before hand :) will we need a pull request to "fix" masonry? |
@anthonygeranio Looking forward for your solution. 💃 @cclion I will try it later, thanks. |
I've had a cell with fixed height and still experienced this problem. The solution that worked for my case was to override
|
it is good@kevinh |
@anthonygeranio Please help, how to fix this issue |
+1, how to fix it |
+1 |
I ran across this same issue. It seems that:
would work prior to iOS 10. After iOS 10, that does not work and I needed:
|
Finally found out the solution for my case, seems like it's not Masonry's fault to blame for this problem. My solution is: Just don't do this
Do NOT call
Hope this will help. |
It worked well before I updated to iOS 10 and Xcode 8.
For example,in a UITableViewCell subclass:
This used to work like a charm in iOS 9 while compiling with XCode 7.x, but now it is not.
Console shows this:
How can I fix this? Thanks a lot.
The text was updated successfully, but these errors were encountered: