Tabs not appearing correctly on iPhone X

0 votes
asked May 29, 2018 in Issue by ts6 (120 points)
I am using basic Material UI Tabs in my mobile app.  The tabs appear correctly when the app is built on Samsung and iOS devices....except for the iPhone X.  They appear correctly when I run the app with the iPhone X dimensions in Unity.  However, when the app is built and run on iPhone X, the tabs seem to be keeping the width they would have on all of the other devices.  Therefore, you see the first tab...and part of the second tab on the screen.  Is there a setting or easy fix to account for the iPhone X dimensions?
commented May 31, 2018 by ts6 (120 points)
I figured I could add a little more to the question.  Basically, due to the sizing issues with the iPhone X, I am resizing the canvas if the device is an X.  My resizing code works on all non-MaterialUI pages.  The error received on the MaterialUI tab page is as follows:

NullReferenceException: A null value was found where an object instance was required.
  at UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate (UnityEngine.RectTransform layoutRoot) [0x00000] in <filename unknown>:0
  at MaterialUI.MaterialSlider.OnCanvasChanged (Boolean scaleChanged, Boolean orientationChanged) [0x00000] in <filename unknown>:0
  at UnityEngine.Events.UnityEvent`2[T0,T1].Invoke (.T0 arg0, .T1 arg1) [0x00000] in <filename unknown>:0
  at MaterialUI.MaterialUIScaler.ApplyScaleSettings (Single currentScale, Single currentPixelsPerUnit, Boolean applyToCanvas) [0x00000] in <filename unknown>:0
  at UnityEngine.UI.CanvasScaler.SetScaleFactor (Single scaleFactor) [0x00000] in <filename unknown>:0
  at UnityEngine.UI.CanvasScaler.HandleScaleWithScreenSize () [0x00000] in <filename unknown>:0

1 Answer

0 votes
answered Jun 2, 2018 by anonymous
Update: I solved the problem by just forcing the Tab View rectTransform as the parameter for ForceRebuildLayoutImmediate via a try/catch.  I'm not sure why it didn't pick it up itself, but this workaround was good enough for the time being.
Welcome to MaterialUI support! Ask us anything :)