Search code examples
iosobjective-cuipickerviewxcode-storyboard

UIPickerView ignoring contraints


I have a view within my app that has a UIPickerView. The delegation and datasource is set up and the picker loads data correctly, however, it ignores storyboard constraints entirely and shifts to the top of the view regardless of what I've tried.

The screenshots below show the alignment in storyboard (the picker is aligned center vertical/horizontal to the blue view (which has a constraint of 30 on all sides) and the alignment when the app is run on a 6S.

Any idea what I'm doing wrong? enter image description here

enter image description here

enter image description here


Solution

  • Remove [self.view addSubview:self.mouthpiecePicker]; This is re-adding the picker view, but it was already added with Storyboard. When you re-add it, it removed all constraints.