问题
I'm working on an app that has two sections, a config section and a results section. My config section needs to be 2 separate views (horizontal and vert, and yes, I can hear the intake of breath from here), with one rotatable view for the results. b/c of layout restraints and a lot of pain around rotation, I'm not using a navigation controller.
I've been experiencing the joys of rotation experimentation and have settled upon keeping my views contained as subviews of my view controller. i.e.
view controller.view.subviews = configH, configV, and results. I then use the controller.view bringSubviewToFront to bring the either the configH, configV, or the result view to the front.
Rotation works-queue(humor intended) the angelic choirs... almost. What's happening is that my configV button's are responsive, but when the device (or simulator) is rotated, my configH controls are not. (configV is the second subview added, but the first one to be brought to the front because app comes up in portrait mode) The controls on the results view also work.
Plan B was to assign the controller.view to configH, configV, or results. All of my controls now work, but rotation is now fouled up.
Question 1: Is there a better way to do this? (a horizontal and vertical config view and a rotatable results view) Question 2: Does the above suggest a design issue, or is it more likely that my addled brain is just missing something in my own code. (nothing from the peanut gallery please)
many thanks!
回答1:
Figured it out. Deleting the old view from IB and building a new uiview from scratch (and rehooking it up) has fixed it. Painful, but effective. Further looking shows that gkedmi ran into the same mess here:Touch Area changing on custom uibutton with image and title on landscape mode
Thanks to everyone who looked at this one!
来源:https://stackoverflow.com/questions/2842355/horizontal-uiviews-controls-unresponsive-or-how-to-foul-up-a-view-hierarchy