Screen controls have inverted vertical order

I have an Objective C project for MacOS in XCode 12.3 running on Catalina. A preferences screen shown at run time has started displaying controls in inverted vertical order, as though the Y origin is at the top (as it is for iOS) rather than the bottom (as it is for MacOS). In design view the ordering is correct. How can I fix this problem?

A preferences screen shown at run time

Is it your preferences screen or a system one ?

If yours, could you give some details:
  • where and how are those controls defined ?

  • show the code if any


The Preferences screen is one which I have modified from another project in which it shows with the expected control order. I have extracted the part of the MainMenu.xib file in which the Preferences window is defined for the modified and original files. Edited versions of both are included below (full versions exceed the size limit for posts, as they comprise about 200 lines each). Modifications include additions of several controls, movement of existing controls and change of window size. Comparison between the modified and the original Preferences window code show many differences, but a significant one may be the inclusion of
Code Block
<point key="canvasLocation" x="-842.5" y="-822.5"/>

before the closing </window> tag in the modified version.

Update: removing the above line seems to fix the problem!

Code Block
Extract from Modified Preferences Window with controls in inverted order
<window title="Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="379" userLabel="Preferences" customClass="NSPanel">
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="391" y="507" width="269" height="375"/>
<rect key="screenRect" x="0.0" y="0.0" width="1280" height="777"/>
<view key="contentView" id="380" customClass="NSButton">
.....
</view>
<point key="canvasLocation" x="-842.5" y="-822.5"/>
</window>

Code Block
Original Preferences Window with controls in expected order
<window title="Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="379" userLabel="Preferences" customClass="NSPanel">
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="391" y="507" width="249" height="199"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1028"/>
<view key="contentView" id="380">
....
</view>
</window>


Update - problem reappeared and the fix described did not work. Canvas location describes where the window is shown in interface view. Tried removing
Code Block
customClass="NSButton"

from
Code Block
<view key="contentView" id="380" customClass="NSButton">

via the Identity Inspector, which showed a greyed out NSView in the Custom Class area after I deleted NSButton.
This resulted in the controls being shown with the correct ordering.
Screen controls have inverted vertical order
 
 
Q