I have a view in my storyboard that seems to be acting like it doesn't want to go where I want it to go. In the debugger, on a breakpoint after adding constraints, I ran
and got a YES response.
Here's the implementation code for the superview class:
Will someone please help? Thanks.
Code:
po (BOOL)CGRectContainsPoint((CGRect)[self bounds],(CGPoint)[textField center])
Here's the implementation code for the superview class:
Code:
-(instancetype)initWithCoder:(NSCoder *)aDecoder
{
self = [superinitWithCoder:aDecoder];
if (self) {
label = [[UILabelalloc] init];
[labelsetText:@"blahblah"];
textField = [[UITextFieldalloc] init];
[textFieldsetText:@"Mr. M"];
[labelsetTranslatesAutoresizingMaskIntoConstraints:false];
[textFieldsetTranslatesAutoresizingMaskIntoConstraints:false];
[labelsetFrame:CGRectMake(150, 50, 100, 100)];
[textFieldsetFrame:CGRectMake(50, 50, 100, 100)];
[textFieldsetClipsToBounds:YES];
[selfaddSubview:label];
[selfaddSubview:textField];
}
returnself;
}
-(void)updateConstraints
{
[superupdateConstraints];
NSDictionary *views = NSDictionaryOfVariableBindings(label,textField);
NSArray *horizConstraints = [NSLayoutConstraintconstraintsWithVisualFormat:@"H:|-0-[label(textField)]-0-|"options:0metrics:nilviews:views];
NSArray *lblHeight = @[[NSLayoutConstraintconstraintWithItem:labelattribute:NSLayoutAttributeToprelatedBy:NSLayoutRelationEqualtoItem:selfattribute:NSLayoutAttributeTopmultiplier:1constant:0],[NSLayoutConstraintconstraintWithItem:labelattribute:NSLayoutAttributeBottomrelatedBy:NSLayoutRelationEqualtoItem:selfattribute:NSLayoutAttributeTopmultiplier:12constant:100]];
NSArray *txtHeight = @[[NSLayoutConstraintconstraintWithItem:textFieldattribute:NSLayoutAttributeBottomrelatedBy:NSLayoutRelationEqualtoItem:selfattribute:NSLayoutAttributeBottommultiplier:1constant:0],[NSLayoutConstraintconstraintWithItem:textFieldattribute:NSLayoutAttributeToprelatedBy:NSLayoutRelationEqualtoItem:selfattribute:NSLayoutAttributeBottommultiplier:1constant:-50]];
[selfaddConstraints:horizConstraints];
[selfaddConstraints:txtHeight];
[selfaddConstraints:lblHeight];
}
Will someone please help? Thanks.