ios - swift subview does not full-fill parent view -


when app starts, use method set root view controller.

func showrootviewcontroller() {     let sb = uistoryboard.init(name: "main", bundle: nil)     let mainviewcontroller = sb.instantiateinitialviewcontroller()!     self.window?.rootviewcontroller = mainviewcontroller     self.window?.makekeyandvisible() } 

in main view controller, i've code set view container view

class mainviewcontroller: uiviewcontroller {      @iboutlet weak var headerview: uiview!     @iboutlet weak var containerview: uiview!      override func viewdidload() {         super.viewdidload()              }      override func viewdidappear(_ animated: bool) {         super.viewdidappear(animated)          if(usermanager.hasregistered()) {             let sb = uistoryboard.init(name: "login", bundle: nil)             self.setcontentviewcontroller(sb.instantiateinitialviewcontroller()!)         } else {             let sb = uistoryboard.init(name: "registration", bundle: nil)             self.setcontentviewcontroller(sb.instantiateinitialviewcontroller()!)         }      }      func setcontentviewcontroller(_ contentviewcontroller: uiviewcontroller) {         print(self.containerview.frame)         let contentview = contentviewcontroller.view!         contentview.frame = self.containerview.bounds         self.containerview.addsubview(contentview)     } } 

let @ view, have container view used add subviews. set background address frame of container view
main view

the subview designed below:
result design

the result not expected. containerview has gone somewhere (i don't know), subview move on top. result view

please me.

contentview frame setted in wrong position. should move line of code:

contentview.frame = self.containerview.bounds 

in

override func func viewdidlayoutsubviews() {     super.viewdidlayoutsubviews()     contentview.frame = self.containerview.bounds } 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -