More iOS Autolayout questions/concerns

So I have a view created in an iOS app. It looks great. I have my controls properly sizing, etc.

Now I add tabs to the IPadScreen object and boom! My auto layout is all messed up. Particularly messed up is the width of my controls. Seems like adding the tabs messes up all the constraints, etc. What gives? That certainly should not happen if we had a framework that works properly or so I would think…

Does adding tabs in the screen object somehow change when constraints get evaluated and applied?

Where does it mess up the constraints?

-In the Xojo IDE
-In the simulator
-On a real device

In the simulator.

So here’s two pics. Same exact code. Only different is tabs added to the screen:


OK. Here is what’s interesting too. If I have this view shown, in Tab0, then it comes out fine on the first tab. It gets messed up on the second tab.

So there’s something I am not doing right with applying constraints for items in tabs other than the first…

Or it’s a bug…

I just wanted to say what an awesome slider control design @Jon Ogden

Looks very professional and 3D realistic. Hope you get that layout issue figured out.

[quote=476499:@Scott Cadillac]I just wanted to say what an awesome slider control design @Jon Ogden

Looks very professional and 3D realistic. Hope you get that layout issue figured out.[/quote]

Thank you. It was a lot of work and I also had help from folks here. Sasha Schepenmueller (I think that is his name) got me started with the base design and I took it from there. The slider handle for example is totally his design. So I can’t take all the credit.

The LEDs light up to and change colors as you go up…

You can do things like leave the LEDs off, set labels and major ticks where you want, etc.

I am happy to let you use the control for either iOS or Desktop if you like…

[quote=476502:@Jon Ogden]I am happy to let you use the control for either iOS or Desktop if you like…
[/quote]
That’s very generous of you. Thank you.

In a former career, I spent nearly 20 years on the road as a Stage Lighting tech (and sometimes Sound guy) doing live concerts and using physical consoles with controls like these. Which is why I noticed the detail.

Most of my app ideas don’t involve this sort of requirement these days, although if I can ever get my Tinnitus sound-masking idea off the ground, I might take you up on the offer :slight_smile:

Now back to your question, sorry to change topics here.

OK. Some more info for everyone…

I’ve been playing around with this. Seems when the second tab is activated there are zero constraints on any of the controls. Everything is at the default 100x100 size. It seems like Activate is similar to the open event for a view. But the View’s open event has already fired as have all the controls. But no constraints have yet been applied.

Setting a timer in the Activate event to apply all the constraints then seems to work. This is all so damn confusing because one would think that by the time a view is activated, that the constraints would already be applied (isn’t that what open is for?).

I sure hope that in the next API for iOS, that Xojo adds a “ConstraintsApplied” event so you can go in there and set custom constraints, etc.

It just seems so kludgy to me…

And here’s a further annoying part. When activating the View when it is in Tab1, I can see the controls all drawn the wrong way for a split second prior to the constraints being applied it and re-drawing correctly. It looks really, really bad. So somewhere, a layout is being done with all the wrong constraints, the view is drawn but it’s not visible on the screen. Then the wrong view is shown.

And I can’t update it any faster as I do a Xojo.Timer.CallLater call with a 1ms delay.

Well, I think I have it…But yuck, what a mess.

1.) I have to set EVERY control on the page to Visible = False
2.) Once the activate event for the view fires I then call Xojo.Core.Timer.CallLater and call my method to set all my programmatic constraints after 1 ms.
3.) In the method setting the constraints, I then make my controls visible at the very end.

This is really, really, really bad. I feel like it’s a total programming kludge. But I don’t know how else to work it…