Closed mythodeia closed 8 years ago
just an update:
for example when i use the BOSwitchTableViewCell
i changed this:
NSLayoutConstraint *rightConstraint = [NSLayoutConstraint constraintWithItem:self.toggleSwitch
attribute:NSLayoutAttributeRight
relatedBy:NSLayoutRelationEqual
toItem:self.toggleSwitch.superview
attribute:NSLayoutAttributeRightMargin
multiplier:1
constant:0];
to this:
NSLayoutConstraint *rightConstraint = [NSLayoutConstraint constraintWithItem:self.toggleSwitch
attribute:NSLayoutAttributeRight
relatedBy:NSLayoutRelationEqual
toItem:self.toggleSwitch.superview
attribute:IS_IOS8 ? NSLayoutAttributeRightMargin : NSLayoutAttributeRight
multiplier:1
constant:IS_IOS8 ? 0 : -16];
and in BOTableViewCell.m
i modified the layoutSubviews to this:
CGFloat yOffset;
if (IS_IOS8) {
yOffset = (self.layoutMargins.top-self.frame.size.height)/2;
}
else{
yOffset = 0;
}
and finally in BOTableViewController.m
for method tableview:willDisplayCell:forRowAtIndexPath
if (IS_IOS8) {
if (cell.layoutMargins.top == 8) {
CGFloat cellHeight = [self tableView:tableView heightForRowAtIndexPath:indexPath];
cell.layoutMargins = UIEdgeInsetsMake(cellHeight, cell.layoutMargins.left, cell.layoutMargins.bottom, cell.layoutMargins.right);
}
}
is there a better way?
Hey there @mythodeia. Thanks for opening this issue.
If you check out v3.0.0 alpha you'll see most of the layoutMargins
code is gone, although it's still a vital part of Bohr because it determines cells height for expansion. I haven't really found any other more efficient, less hacky way to do it, but I'll keep looking for a better solution. When I find it, iOS 7 support will be totally achievable.
if you want, we can leave this issue open until IOS 7 support is fully achievable then. keep up the great work. thanks :+1:
Sure! I'll definitely keep this open.
@mythodeia thanks for your advice. I meet this crash in iOS7 right now,but when I change the code just as you said,the crash appear again. It seems that the [xxx setPreservesSuperviewLayoutMargins] is still unrecognized selector sent to instance 0x166556c0 . Did you combat this issue in iOS7?
@liuyan3176 i did not have any issues with that change. However in that app i used IOS 8 and above.
I'm afraid iOS 7 support won't be possible in the future due to my plans of releasing a major, Swify 4.0 version (#22). Sorry for that!
it crashes when using the
layoutMargins
is there any solution for apps that still support IOS 7? thanks