ios - Child view controller resizes when I reopen the height -
i have 3 view controllers embed inside scrollview, snapchat style (so can swipe between them). i'm facing weird problem nav bar appears squished against status bar,
but when leave app (go home screen example) , come back, moves down.
here's code:
let storyboard = uistoryboard(name: "main", bundle: bundle.main) self.mainscrollview.delayscontenttouches = false let v1 = storyboard.instantiateviewcontroller(withidentifier: "profileviewcontroller") as! profileviewcontroller self.addchildviewcontroller(v1) self.mainscrollview.addsubview(v1.view) v1.didmove(toparentviewcontroller: self) //-------- let v2 : recordviewcontroller = recordviewcontroller(nibname: "recordviewcontroller", bundle: nil) self.addchildviewcontroller(v2) self.mainscrollview.addsubview(v2.view) v2.didmove(toparentviewcontroller: self) //-------- let v3 = storyboard.instantiateviewcontroller(withidentifier: "discoverviewcontroller") as! discoverviewcontroller self.addchildviewcontroller(v3) self.mainscrollview.addsubview(v3.view) v3.didmove(toparentviewcontroller: self) //-------- var v1frame : cgrect = self.mainscrollview.bounds v1frame.origin.x = 0 v1.view.frame = v1frame //v1.view.bindframetosuperviewbounds() var v2frame : cgrect = self.mainscrollview.bounds v2frame.origin.x = self.view.frame.width v2.view.frame = v2frame var v3frame : cgrect = self.mainscrollview.bounds v3frame.origin.x = self.view.frame.width*2 v3.view.frame = v3frame
my solutions far have been programmatically adding constraints, can't figure out should add constraints to. here's tried
let csh = nslayoutconstraint.constraints(withvisualformat: "h:|-0-[v]-0-|", options: [], metrics: [:], views: ["v": recordview]) let csv = nslayoutconstraint.constraints(withvisualformat: "v:|-0-[v]-0-|", options: [], metrics: [:], views: ["v": recordview]) view.addconstraints(csh) view.addconstraints(csv)
select field want edit. make settings picture. hope helps.
Comments
Post a Comment