简体   繁体   中英

App crashes, NSInvalidLayoutConstraintException, red exclamation in iOS storyboard designer ViewController

Two main issues, which may be related:

  1. Mobile app is crashing immediately after launch screen. May be due to a UI problem.
  2. In the storyboard designer, a ViewController (only 1) is not scaling when a different screen size is selected, and has a red exclamation point.

I recently updated Xamarin.iOS in Visual Studio for Mac to accommodate Apple's iOS 11.3 and Xcode 9.3 updates, and my app crashes immediately after launching (launch screen appears, then app crashes & closes). I can't find any error messages in the output / console.

On my Main.Storyboard, there is a red exclamation mark in the lower right corner of my main ViewController . Clicking this reveals the following NSInvalidLayoutConstraintException error details: 抛出Foundation.MonoTouchException。

Also, when I change the "Viewing: iPhone [various versions]" to change the preview screen size of each ViewController's UI, this same ViewController that has the red exclamation mark retains all of it's elements squished in the iPhone SE layout. That is, when I select "iPhone 8 Plus" for example, the elements don't expand to fill the entire ViewController , while other ViewControllers have no issues expanding: iPhone SE和iPhone 8 Plus

I don't see any problematic constraints - I've gone over each constraint in Document Outline - none seem to be referencing erroneously. I've heard you can accidentally reference incompatible constraints, like label.X to a another UIView.Y ... Yet when dragging / creating a constraint some lines appear as dotted and red, not allowing the [incompatible?] constraint to be made.

Any help appreciated! Thanks in advance!!

The constraint causing the red exclamation mark AS WELL AS causing the app to crash was somewhat defined in the NSInvalidLayoutConstraintException error, top-right line. It doesn't give the name of the element upon which the constraint is defined, but it says:

.....'UIViewSafeAreaLayoutGuide'.top == UIView:......leading + 20

and with that I was able to narrow down which constraint it was in Document Outline. I don't know HOW I managed to tie a .top to a .leading, but it was there.

Hope this helps someone! I Spent several days trying to fix it! :-G |-{ Cheers!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM