ios - Unable to simultaneously satisfy constraints after updating height -
the big image view has "scale fill" content mode.
i don't know size of image before load sdwebimage, i've created constant height constraint , outlet in code.
when image loaded, i'm changing height constraint's constant keep image's aspect:
imageiv.sd_setimage(with: feedad.getimageurl(), completed: { (image: uiimage?, error: error?, cachetype: sdimagecachetype!, imageurl: url?) in if image != nil { let ratio = image!.size.height / image!.size.width self.imageheightconstraint.constant = self.imageiv.frame.width * ratio self.updateconstraints() } else { print("image == nil!") } if self.imageviewloadedcallback != nil { self.imageviewloadedcallback!() } })
and see following:
2017-01-13 00:21:10.387862 dotato[1541:503878] [layoutconstraints] 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. ( "<nslayoutconstraint:0x17008df70 uiimageview:0x102d39000.height == 48>", "<nslayoutconstraint:0x174098bf0 uiimageview:0x102e59e40.height == 228.667>", "<nslayoutconstraint:0x17409bc10 uiimageview:0x102d39000.top == uitableviewcellcontentview:0x102d4bae0.top + 8>", "<nslayoutconstraint:0x174098010 uiimageview:0x102e59e40.top == uiimageview:0x102d39000.bottom + 8>", "<nslayoutconstraint:0x17409aae0 uibutton:0x102e6c600.top == uiimageview:0x102e59e40.bottom + 16>", "<nslayoutconstraint:0x17409aa40 uitableviewcellcontentview:0x102d4bae0.bottom == uibutton:0x102e6c600.bottom + 8>", "<nslayoutconstraint:0x17009be40 uitableviewcellcontentview:0x102d4bae0.height == 293>" ) attempt recover breaking constraint <nslayoutconstraint:0x174098bf0 uiimageview:0x102e59e40.height == 228.667>
the cell height not updated, view height-cutted. when scroll table view down unless cell becomes out of screen , scroll it, resizes correctly.
so, have 2 questions:
- how resolve error?
- how make cell adjust it's height correctly?
Comments
Post a Comment