2

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

Boid
  • 1,161
  • 1
  • 11
  • 21

2 Answers2

4

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

Kostiantyn Koval
  • 8,407
  • 1
  • 45
  • 58
0

In the storyboard, you can simply control drag a connection from your button to your presented Viewcontroller. There's no reason to have a @IBAction for this. If you use the InterfaceBuilder approach you can optionally set the presentation style on the segue to PageSheet.

  • Yes I did all this. Like I mentioned in the question I have attempted this in the storyboard and programmatically (separately). – Boid Nov 06 '14 at 17:27
  • Ah sorry, misread that second part. Can you add a screenshot of your document outline for that controller? – Philipp H. Nov 06 '14 at 17:32
  • Added it. Not much to see to be honest. I tried to keep it as simple as possible. – Boid Nov 06 '14 at 17:38
  • Can you make sure, that this is not an auto layout issue? Meaning, that the label doesn't get a height of 0 or something like that? – Philipp H. Nov 06 '14 at 17:54
  • I pinned the height and the width and got the same result. Also the label is visible in the preview just not in the simulator or ipad. – Boid Nov 06 '14 at 18:06