Your answers inspired me to keep trying. I have found a way to re-apply auto-layout when the iPad is rotated.
First thing is the simulator (26.0) does not fire the MobileScreen.OrientationChanged event reliably. For me it fires at startup and never again. I will have to build and test on a real iPad to determine if the problem is simply the simulator.
But the MobileScreen.Resized event does fire reliably when I rotate from portrait to landscape so I used that event to re-invoke auto-layout.
I have always had defined auto-layout parameters and a set of sizes and spacings for each iPad screen size. Just had to add new screen sizes for the landscape orientation. Here is some code:
SetColorSqrSize (scrnWidth as Integer, ByRef w as iOSLayoutConstraint, ByRef h as iOSLayoutConstraint, ByRef l as iOSLayoutConstraint)
select case scrnWidth
case 744 //Mini6Gen
h.Offset=56
w.Offset=56
l.Offset=kPadLeft25
case 768
h.Offset=60
w.Offset=60
l.Offset=23
…
Here is the code called by the Resized event:
dim reOrient as Boolean
dim w as iOSLayoutConstraint
dim h as iOSLayoutConstraint
dim l as iOSLayoutConstraint
//first save pCurrentOrientation for comparison
dim previousOrient as integer=app.pCurrentOrient
//now set new orientation
app.SetCurrentOrientation
select case app.pCurrentOrient
case 0
//do nothing
case 1
if previousOrient<>1 then
reOrient=true
end if
case 2
if previousOrient<>2 then
reOrient=true
end if
end select
if reOrient then
dim wArray() as string=Array(“clrSqr0Width”,“clrSqr1Width”,“clrSqr2Width”,“clrSqr3Width”,“clrSqr4Width”,“clrSqr5Width”,“clrSqr6Width”,“clrSqr7Width”,“clrSqr8Width”)
dim hArray() as string=Array(“clrSqr0Height”,“clrSqr1Height”,“clrSqr2Height”,“clrSqr3Height”,“clrSqr4Height”,“clrSqr5Height”,“clrSqr6Height”,“clrSqr7Height”,“clrSqr8Height”)
dim lArray() as string=Array(“clrSqr0Left”,“clrSqr1Left”,“clrSqr2Left”,“clrSqr3Left”,“clrSqr4Left”,“clrSqr5Left”,“clrSqr6Left”,“clrSqr7Left”,“clrSqr8Left”)
dim i as integer
for i=0 to 8
w=self.Constraint(wArray(i))
h=self.Constraint(hArray(i))
l=self.constraint(lArray(i))
SetColorSqrSize(self.Size.Width,h,w,l)
next
end if
The secret here is the “self.contraint” knows which canvas is referred to by the constraint name.