2

Example project: http://cl.ly/1g1L3E2Z0r1c

I create a nib file and then create some views in it, which I then load into another view controller. In the view that I bring in, it's a subclass of UIView where I have outlets set up for its properties. I have one specifically for its constraint from distance from the top.

But when I try to access it in code (like as follows), I can't, it states it's null:

self.tutorialScreen3.textLabelDistanceFromTop.constant += 150.0;
NSLog(@"%@", self.tutorialScreen3.textLabelDistanceFromTop);

What am I doing wrong?

1 Answer 1

0

In this line

[[[NSBundle mainBundle] loadNibNamed:@"View" owner:nil options:nil] lastObject];

you're loading the last view from your View.xib file, and it's view 3, but you're property textLabelDistanceFromTop is not connected with this view, but with view 2.

You just need to make in view 3 the same constraints you made in view 2 and to connect the textLabelDistanceFromTop property with appropriate constraint in view 3, and it wan't be nil any more.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.