ios - Xcode Unable to change second childViewController's frame -


i have menuviewcontroller , inside viewcontroller have 2 childviewcontrollers first 1 on left part , second 1 on right side.

view_width = self.view.frame.size.width; width_listtableview = 0.4;  listviewcontroller *listviewcontroller  = [[listviewcontroller alloc] init]; listnavigationviewcontroller *listviewnavigation = [[listnavigationviewcontroller alloc] initwithrootviewcontroller:listviewcontroller]; [self addchildviewcontroller:listviewnavigation]; [self.view insertsubview:listviewnavigation.view belowsubview:self.searchbarview.view]; [listviewnavigation didmovetoparentviewcontroller:self]; listviewnavigation.view.frame   = cgrectmake(0,                                              y,                                              view_width*width_listtableview,                                              height);       previewviewcontroller *readviewcontroller = [[previewviewcontroller alloc] init]; [self addchildviewcontroller:readviewcontroller]; [self.view insertsubview:readviewcontroller.view belowsubview:listviewnavigation.view]; [readviewcontroller didmovetoparentviewcontroller:self]; readviewcontroller.view.frame = cgrectmake(listviewnavigation.view.frame.origin.x + listviewnavigation.view.frame.size.width,                                            listviewnavigation.view.frame.origin.y,                                            view_width - listviewnavigation.view.frame.size.width,                                            listviewnavigation.view.frame.size.height); 

but cannot change frame of readviewcontroller , width , height (768.0, 1024.0).

i added constraint listviewnavigation, listviewnavigation.view.y = 0

- (void)addconstraintwithlistnavigationviewcontroller:(uiview *)listviewnavigation y:(cgfloat)y height:(cgfloat)height {     //set x = 0;     nslayoutconstraint *constrainttoanimate1 = [nslayoutconstraint constraintwithitem:listviewnavigation                                                                             attribute:nslayoutattributeleft                                                                             relatedby:nslayoutrelationequal                                                                                toitem:self.view                                                                             attribute:nslayoutattributeleft                                                                            multiplier:0.00                                                                              constant:0];     [self.view addconstraint:constrainttoanimate1];       //set y = y;     nslayoutconstraint *constrainttoanimate2 = [nslayoutconstraint constraintwithitem:listviewnavigation                                                                             attribute:nslayoutattributetop                                                                             relatedby:nslayoutrelationequal                                                                                toitem:self.view                                                                             attribute:nslayoutattributebottom                                                                            multiplier:0.00                                                                              constant:y];     [self.view addconstraint:constrainttoanimate2];             //set width = self.view.frame.size.width*0.4     nslayoutconstraint *constrainttoanimate3 = [nslayoutconstraint constraintwithitem:listviewnavigation                                                                             attribute:nslayoutattributewidth                                                                             relatedby:nslayoutrelationequal                                                                                toitem:self.view                                                                             attribute:nslayoutattributewidth                                                                            multiplier:width_listtableview                                                                              constant:0.0];     [self.view addconstraint:constrainttoanimate3];          //set height = height     nslayoutconstraint *constrainttoanimate4 = [nslayoutconstraint constraintwithitem:listviewnavigation                                                                             attribute:nslayoutattributeheight                                                                             relatedby:nslayoutrelationequal                                                                                toitem:nil                                                                             attribute:nslayoutattributenotanattribute                                                                            multiplier:0.00                                                                              constant:height];     [self.view addconstraint:constrainttoanimate4]; } 

this because have auto layout enabled. try update constraints after changing frame using function [readviewcontroller.view settranslatesautoresizingmaskintoconstraints:yes]


Comments