0

I have some views that are not positioning right. In my project, I've linked the positioning to a slider to try and make sure it's happening and it keeps snapping back and forth visually as I drag the slider. I've stripped everything down and made a test project to try and figure this out and while it doesn't snap back and forth, it doesn't appear to work when viewWillAppear is called, only when doing after by dragging the slider. Screenshots and project attached.

Initial positioning reflecting the position in IB

The positioning I want to set programmatically at the start that shows when dragging the slider

Example code: http://www.hyperfileshare.com/d/b7e4b088

Kudit
  • 4,212
  • 2
  • 26
  • 32
  • Can't download from there, you might want to use file-sharing service with less restrictions. As for the question, make sure the view of the viewcontroller is loaded at the moment you are using is't outlets (haven't seen the code yet). – A-Live Jan 09 '13 at 21:15

1 Answers1

7

You are using autolayout, a new iOS 6 feature that controls the placement of controls not by hard coded coordinates, but rather by a collection of rules called "layout constraints". See the Cocoa Auto Layout Guide for more information. Bottom line, with autolayout, you can't move items by just changing frame coordinates.

To see your "autolayout" setting, open the storyboard and open the "File inspector" in the panel on the right (e.g. press option+command+1) and look at the "Use Autolayout" setting.

If you want to use autolayout, you move items on your view by changing the view constraints, not by changing the frame. See Autolayout seems not working when changing view dimensions programmatically.

Community
  • 1
  • 1
Rob
  • 415,655
  • 72
  • 787
  • 1,044