ios - How to disable autolayout for individual UI elements (UIlabel) -
i need change position of label inside viewcontroller uses autolayout. before used
[arrivetimelabel settranslatesautoresizingmaskintoconstraints:yes]; [departtimelabel settranslatesautoresizingmaskintoconstraints:yes]; but yields runtime warnings
break on objc_exception_throw catch in debugger. methods in uiconstraintbasedlayoutdebugging category on uiview listed in <uikit/uiview.h> may helpful. 2013-08-15 23:25:58.791 vicinitime[78327:c07] unable simultaneously satisfy constraints. @ least 1 of constraints in following list 1 don't want. try this: (1) @ each constraint , try figure out don't expect; (2) find code added unwanted constraint or constraints , fix it. (note: if you're seeing nsautoresizingmasklayoutconstraints don't understand, refer documentation uiview property translatesautoresizingmaskintoconstraints) ( "<nslayoutconstraint:0x9173a20 uiscrollview:0x9580190.bottom == uiview:0x9173890.bottom>", "<nslayoutconstraint:0x9171fe0 v:|-(138)-[uilabel:0x958cf70] (names: '|':uiscrollview:0x9580190 )>", "<nslayoutconstraint:0x91739a0 v:|-(0)-[uiscrollview:0x9580190] (names: '|':uiview:0x9173890 )>", "<nsautoresizingmasklayoutconstraint:0xab6ec90 h=--& v=&-& uilabel:0x958cf70.midy == -6.3989*uiscrollview:0x9580190.height>", "<nsautoresizingmasklayoutconstraint:0xab6eef0 h=--& v=&-& v:[uilabel:0x958cf70(25)]>", "<nsautoresizingmasklayoutconstraint:0xab6dbd0 h=--& v=--& v:[uiview:0x9173890(455)]>" ) attempt recover breaking constraint <nslayoutconstraint:0x9171fe0 v:|-(138)-[uilabel:0x958cf70] (names: '|':uiscrollview:0x9580190 )> so looked around , saw fix problem have set [arrivetimelabel settranslatesautoresizingmaskintoconstraints:no]; [departtimelabel settranslatesautoresizingmaskintoconstraints:no];
to no. problem labels arn't changing position programmatically.
if need code set labels programatically:
if(traveltimeint <= activitytimeint){ [timebreakdownbuttonimage setbackgroundimage:[uiimage imagenamed:@"timebreakdownbackground7.png"] forstate:uicontrolstatenormal]; nslog(@"got setting label place"); [self.arrivetimelabel setframe:cgrectmake(67, 170, 41, 25)]; [self.departtimelabel setframe:cgrectmake(211, 170, 41, 25)]; } if(traveltimeint * 7 >= activitytimeint){ [timebreakdownbuttonimage setbackgroundimage:[uiimage imagenamed:@"timebreakdownbackground6.png"] forstate:uicontrolstatenormal]; nslog(@"got setting label place"); self.arrivetimelabel.frame = cgrectmake(71, 170, 41, 25); self.departtimelabel.frame = cgrectmake(207, 170, 41, 25); } so there way change position of uilabel autolayout on? maybe disable autolayout?
if you're using autolayout uiviews positioned based on nslayoutconstraints.
to move them, rather set frames need alter constraints.
Comments
Post a Comment