aaronfalls
aaronfalls

Reputation: 201

Storyboard constraints don't seem to be applied

I am using constraints to lay out a view controller in my app. Here is a screenshot of the completed layout: enter image description here

From what I've read, the constraints being blue means they are good (there is enough information to determine layout).

In another view controller, I am presenting this view controller with a popover presentation style like this:

- (void)annotationTapped:sender {
  ...

  AJFAnswerViewController *answerViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"AnswerViewController"];

  answerViewController.modalPresentationStyle = UIModalPresentationPopover;
  [self presentViewController:answerViewController animated:YES completion:nil];

  answerViewController.answerLabel.text = tappedAnnotation.name;
  answerViewController.quesitonLabel.text = tappedAnnotation.questionText;
  answerViewController.saveBlock = saveBlock;

  UIPopoverPresentationController *popover = [answerViewController popoverPresentationController];
  popover.sourceView = tap.view;
  popover.sourceRect = tap.view.bounds;
  popover.permittedArrowDirections = UIPopoverArrowDirectionAny;
}

Here is what I see when I run the app:

enter image description here

It seems that the constraints are not being applied. I have verified that my storyboard ID is correct, and that the popover is using the view controller in the popover (for example, if I change the explicit height to something like 100, it is respected).

Am I missing a specific method call, or going about the storyboard layout wrong?

Upvotes: 2

Views: 116

Answers (2)

wuxueqian
wuxueqian

Reputation: 64

  1. select all the labels and make them embed in a new view (Xcode-editor-embed-view)
  2. select the view which the labels embeded in and add a new alignment constraint (horizontal center in container : 0; vertical center in container : 0)
  3. rebuild those label constraint

Upvotes: 0

aaronfalls
aaronfalls

Reputation: 201

Resolved by applying the constraints to the wAny hAny size (as suggested by Dean, thanks!).

Upvotes: 1

Related Questions