Search code examples
swiftuiviewcontrollerios8presentviewcontrolleruimodalpresentationstyle

UIModalPresentationStyle.PageSheet does not display ViewController content


I currently have a segue that presents a VC modally in PresentationStyle.PageSheet. I have done this both programmatically and with just the storyboard. I get the same result with both approaches, the modal pop over presents itself but does not show any content inside the UIView from the VC. It will only show the background color of the view and that is all. I also want to point out that everything is displayed if I do a default modal segue (full screen) but fails with page sheet presentation style or with using UIPopoverController. Here are some screen shots that show what I am talking about.

This is what it looks like in the storyboard: storyboard

This is what it looks like in the simulator and on an actual ipad: enter image description here

Here is what my coding approach looked like:

@IBAction func addPickUp(){
    var addPickupVC = self.storyboard?.instantiateViewControllerWithIdentifier("pickup") as AddPickupViewController
    addPickupVC.modalPresentationStyle = UIModalPresentationStyle.PageSheet
    self.presentViewController(addPickupVC, animated: true, completion: nil)
}

This written in swift for ipad ios8. What am I missing here? Any constructive feed back is appreciated!

EDIT: Here is the document outline of the VC that is to presented modally. outline


Solution

  • Your code for presenting popover is correct.
    Probably there is problem with AutoLayout constraints.
    As you can see your popover is presented but label is missing.

    1. Remove your AutoLayout (they will be auto generated) and see if the label will be visible now
    2. Try to add new label. Drag and drop it, and don't specify any constraints
    3. Debug your view

      • Click "Debug view hierarchy" button at the debug panel

        enter image description here

      • Now you can see your view hearty. Select your label, if it's present and see it's constraints.

        enter image description here

    4. Check your AutoLayout constraints and Label is present in correct Size Classes
      Size classes is shown bellow UI designer. In my case it's (Any Any).
      It means that it's for all sizes and all devices.
      Also check that your constrains is not removes at runtime.
      You can see it on inspector in right side.

      enter image description here