将一个 xib 粘贴到另一个 xib 上
paste one xib onto another xib
我想将蓝色视图粘贴到黄色视图上。
但是,无论我如何更改蓝色的自动布局,都存在冲突。
按下中间的按钮,然后显示视图。
将此行添加到您的文件 maned UIViewController+testAlert.m
containerFrame.size.width = view.frame.size.width;
就在
之后
containerFrame.size.height = view.frame.size.height;
所以你的 showAlertViewB 函数代码会像
if (show) {
NSArray* nibViews = [[NSBundle mainBundle] loadNibNamed:@"AlertViewB" owner:self options:nil];
alertViewB = (AlertViewB*)[nibViews objectAtIndex:0];
// [alertViewB removeConstraint:alertViewB.containerHeightConstraint];
// NSLayoutConstraint *newContainerHeightConstraint = [NSLayoutConstraint constraintWithItem:alertViewB attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:view.frame.size.height];
// [alertViewB addConstraint:newContainerHeightConstraint];
CGRect containerFrame = alertViewB.container.frame;
containerFrame.size.height = view.frame.size.height;
containerFrame.size.width = view.frame.size.width;
[alertViewB.container setFrame:containerFrame];
[alertViewB setTranslatesAutoresizingMaskIntoConstraints:YES];
alertViewB.delegate =self;
[alertViewB showWithView:view];
} else {
[alertViewB removeFromSuperview];
alertViewB = nil;
}
我想将蓝色视图粘贴到黄色视图上。
但是,无论我如何更改蓝色的自动布局,都存在冲突。
按下中间的按钮,然后显示视图。
将此行添加到您的文件 maned UIViewController+testAlert.m
containerFrame.size.width = view.frame.size.width;
就在
之后containerFrame.size.height = view.frame.size.height;
所以你的 showAlertViewB 函数代码会像
if (show) {
NSArray* nibViews = [[NSBundle mainBundle] loadNibNamed:@"AlertViewB" owner:self options:nil];
alertViewB = (AlertViewB*)[nibViews objectAtIndex:0];
// [alertViewB removeConstraint:alertViewB.containerHeightConstraint];
// NSLayoutConstraint *newContainerHeightConstraint = [NSLayoutConstraint constraintWithItem:alertViewB attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:view.frame.size.height];
// [alertViewB addConstraint:newContainerHeightConstraint];
CGRect containerFrame = alertViewB.container.frame;
containerFrame.size.height = view.frame.size.height;
containerFrame.size.width = view.frame.size.width;
[alertViewB.container setFrame:containerFrame];
[alertViewB setTranslatesAutoresizingMaskIntoConstraints:YES];
alertViewB.delegate =self;
[alertViewB showWithView:view];
} else {
[alertViewB removeFromSuperview];
alertViewB = nil;
}