[SOLVED] Black screen when presenting ParticleSetupMainController on iOS


I’m working on an iOS app for our Particle connected equipment.

As you’d expect there is a point in the storyboard where the user can tap a button to say they want to setup a new device, and that triggers the calling of this code (basically straight from the doco):

if let setupController = ParticleSetupMainController()
    setupController.delegate = self
    self.present(setupController, animated: true, completion: nil)

Now when I first started writing the app I had this code in and it worked, and in fact worked up until quite recently. However I must have done something somewhere else in the app and now when the call to present happens and I’d previously see the displaying of the Particle Setup wizard, now I just get a black screen.

Has anyone seen this before or have an inkling what might be going on, ie a black screen when presenting another view controller?


Are you getting any errors in the console when you run this in Xcode?

[UPDATE] So the constraint warnings/errors were just due to my use of an external hardware keyboard instead of the “onscreen” keyboard of the simulator, so that was a red herring, however it is still the case that it displays on an iPhone but not on an iPad.

[UPDATE] Ok, so another thing that had changed was that initially I was targeting an iPhone, but had recently moved to targeting an iPad, and when I changed the simulator back to an iPhone the ParticleSetup view controller presented correctly. And I’ve found that those few pages worth of repeated constraint issue warnings/errors don’t appear.

So has anyone previously had the ParticleSetup SDK run successfully on an iPad (simulator or real)?

Good point.

So there are no warnings/errors/output of any kind when I make the self.present call.

Earlier on in the workflow of the app (ie when I’m still a couple of screens back from where that ViewController is constructed), I do get a heap of warnings about being unable to simultaneously satisfy constraints, which is interesting because as a test I have removed all constraints from my Storyboard and I still get the errors. Is it possible that these are from the ParticleSetup framework?

 [LayoutConstraints] Unable to simultaneously satisfy constraints.
	Probably at least one of the constraints in the following list is one you don't want. 
	Try this: 
		(1) look at each constraint and try to figure out which you don't expect; 
		(2) find the code that added the unwanted constraint or constraints and fix it. 
	(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
    "<NSAutoresizingMaskLayoutConstraint:0x604000281040 h=--& v=--& UIKeyboardAssistantBar:0x7fe94fd1fcc0.height == 0   (active)>",
    "<NSLayoutConstraint:0x604000094050 V:|-(0)-[_UIButtonBarStackView:0x7fe94fd23240]   (active, names: '|':UIKeyboardAssistantBar:0x7fe94fd1fcc0 )>",
    "<NSLayoutConstraint:0x6040000941e0 V:[_UIButtonBarStackView:0x7fe94fd23240]-(0)-|   (active, names: '|':UIKeyboardAssistantBar:0x7fe94fd1fcc0 )>",
    "<NSLayoutConstraint:0x604000280c80 'UISV-canvas-connection' UILayoutGuide:0x6040001a48a0'UIViewLayoutMarginsGuide'.top == _UILayoutSpacer:0x6040001c7ad0'UISV-alignment-spanner'.top   (active)>",
    "<NSLayoutConstraint:0x604000280cd0 'UISV-canvas-connection' UILayoutGuide:0x6040001a48a0'UIViewLayoutMarginsGuide'.bottom == _UILayoutSpacer:0x6040001c7ad0'UISV-alignment-spanner'.bottom   (active)>",
    "<NSLayoutConstraint:0x604000093ba0 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x6040001a48a0'UIViewLayoutMarginsGuide']-(9)-|   (active, names: '|':_UIButtonBarStackView:0x7fe94fd23240 )>",
    "<NSLayoutConstraint:0x604000093b00 'UIView-topMargin-guide-constraint' V:|-(10)-[UILayoutGuide:0x6040001a48a0'UIViewLayoutMarginsGuide']   (active, names: '|':_UIButtonBarStackView:0x7fe94fd23240 )>"

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x604000280cd0 'UISV-canvas-connection' UILayoutGuide:0x6040001a48a0'UIViewLayoutMarginsGuide'.bottom == _UILayoutSpacer:0x6040001c7ad0'UISV-alignment-spanner'.bottom   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.

SOLVED: (noting it here in case it helps someone in the future)

So what I missed that is in the the example app, though not in the documentation is this line:
setupController.modalPresentationStyle = .formSheet // use that for iPad
which even has a nice comment to make you pay attention.

Seems the Particle Setup view controller is not able to run on an iPad in fullscreen mode.

1 Like