ios - Remove one view's layout constraints but keep its subviews'? -


working on project in ios 8 using storyboard , auto layout:

  1. in storyboard, specified constraints view , subviews
  2. in code, in response touch events, i'm going change view's size setting frame

to make both 1 , 2 warning free, i'm doing following when first changing size code:

[theview removeconstraints:theview.constraints]; theview.translatesautoresizingmaskintoconstraints = yes; theview.frame = cgrectmake(0,0,width,height); 

if not doing first line, xcode complain whole bunch constraint conflicts, adding line remove subview's constraints well. question is: there way remove uiview's constraints not subview, button on still wants center self relative view's size , position?

first, don't need resize view setting frame otherwise point of keeping constraint @ first place. have position having correct initial frame.

secondly, have mis-conception "to-whom" constraint has been applied to.

say button on still wants center self relative view's size , position?

when apply position related constraint view apply it's superview. means if want position subview in horizontal centre of view constraint added on view not on subview. that's why when called removecontraints: message on view position constraint removed , subview isn't bound constraint. width , height constraints applied subviews itself.

to solve need make iboutlets constraint need modify, in case should width, height, horizontal x , top constraint; , change constant values them respectively.

theview.widthconstraint.constant = newvalue; 

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -