Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incredibly, storyboard view order is not respected for container view views, fix?

Glance here ... https://stackoverflow.com/a/34736594/294884

enter image description here

in iOS the order in which you put sibling views, in the Inspector in Storyboard, of course becomes their z-order.

I was amazed to learn that this does not seem to apply to any such views that are container views.

To test, just make a scene with a few sibling views; a couple of them are container views. Run. Change something innocent in the class of the container view controllers (say, add a ViewDidLoad, constraint, or a print statement) and try again. The container view views are randomly moved to the top.

I find the only workaround is: manually put them in order, in viewWillAppear, which is nuts.

1) could it be I've just screwed something up - maybe there's a setting ("respect storyboard order - even for container views!")

2) I've been scratching my head trying to figure out how to "automate" the workaround fix. You'd need to read the order of all views from the storyboard as it's loaded? And then "fix" it at viewWillAppear time. Tricky.

3) could there perhaps be some trick .. in prepareForSegue say? .. to force them to be in correct Z-order, like any view!??


A fix...

One ridiculous fix for this just occurred to me.

Say you have a stretch of your storyboard with 10 sibling views, and say 4 of those are container views. (So, it actually won't work - as described here.)

In fact, make it that even those four views are just (pointless) ordinary UIView, which are holders for the container views. Suck!

like image 333
Fattie Avatar asked Oct 30 '22 02:10

Fattie


1 Answers

That's odd.

What if you put each container view inside an ordinary UIView, with all of the container view's edges pinned to the ordinary UIView? I bet you 5 bucks that fixes it.

like image 95
Duncan C Avatar answered Nov 14 '22 20:11

Duncan C