Hello All!
Everything I've read (Xcode online docs, iOS programming manuals, etc.) indicate that the best way to move a subview within its parent is to change its .center (.x or .y) property.
I have been trying to figure this out for a bit now and the only way I can make a subview move is to change the .frame.orgin of its parent, which moves all the subviews - not what I want.
Why can't I make changing .center work in the following code snipet (self is the parent View Controller)?
// Load POI menus
let poiMenus = Bundle.main.loadNibNamed("POIMenuViews", owner: nil)!
let primaryPOIMenu = poiMenus[0] as! UIStackView
self.view.subviews[0].addSubview(primaryPOIMenu) // works down to here
primaryPOIMenu.center.x += 88 // This NO WORKY!!! Why???
NOTE: The primaryPOIMenu.center.x IS changing (confirmed) but the subview is not moving. I tried using .center similarly in another place and that subview didn't move either.
I'm very confused - this should be simple.
Thanks in advance.
Well, I solved the problem days ago using Outlets to grab references to the menu objects in the NIB and also used constraints position and then reposition them, rather than trying to manipulate the 'center' properties.
It also had something to do with the way I was setting up the NIB positioning criteria in the UI Builder - still haven't quite figured that out yet...
Thanks to all for your input!
Take care!