ios - UIViewController: adjust contraints of xib -


in project defined xib , viewcontroller contain xib.

class feeddetailviewcontroller: uiviewcontroller, feeddetaildelegate {    var feeddetail: feeddetail!    override func viewdidload() {     super.viewdidload()     feeddetail = (nsbundle.mainbundle().loadnibnamed("feeddetail", owner: self, options: nil)[0] as? uiview)! as! feeddetail     feeddetail.delegate = self;     self.view.addsubview(feeddetail)     self.adjustcontraints()   }   func adjustcontraints() {       feeddetail.sizethatfits(self.view.frame.size)      var constraint = nslayoutconstraint(item: feeddetail,         attribute: nslayoutattribute.bottom, relatedby: nslayoutrelation.equal, toitem: view, attribute: nslayoutattribute.bottom, multiplier: 1, constant: 0)     view.addconstraint(constraint)      constraint = nslayoutconstraint(item: feeddetail,         attribute: nslayoutattribute.top, relatedby: nslayoutrelation.equal, toitem: view, attribute: nslayoutattribute.top, multiplier: 1, constant: 0)     view.addconstraint(constraint)      constraint = nslayoutconstraint(item: feeddetail,         attribute: nslayoutattribute.trailing, relatedby: nslayoutrelation.equal, toitem: view, attribute: nslayoutattribute.trailing, multiplier: 1, constant: 0)     view.addconstraint(constraint)      constraint = nslayoutconstraint(item: feeddetail,         attribute: nslayoutattribute.leading, relatedby: nslayoutrelation.equal, toitem: view, attribute: nslayoutattribute.leading, multiplier: 1, constant: 0)     view.addconstraint(constraint)      self.view.layoutifneeded()  } 

what want xib @ "fullscreen", xib borders not "sticked" main view of controller.

enter image description here

border legend:

  • red: self.view
  • yellow: feeddetail
  • others: element inside feeddetail (test only)

try call method before adding constraints.

feeddetail.settranslatesautoresizingmaskintoconstraints(false) 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -