title: Why I init the uiview and the uiview also deinit by swift?
body: <p>I want to manage memory so I want to deinit the UIview when leaving ViewController.<br>
  And I try to use keyword "weak" and I get crash because my chatkeyboard is nil.<br>
  I dont know why making it crash.<br>
  Thanks.<br></p>
  
  <pre><code>class ChatKeyboard: UIView {
  
  var buttonMic:UIButton = { ()-&gt;UIButton in
      let ui:UIButton = GeneratorButton()
      return ui
  }()
  
  override init(frame: CGRect) {
      super.init(frame: frame)
      print("===) ChatKeyboard init.")
      translatesAutoresizingMaskIntoConstraints = false
      loadContent()
      loadConstrain()
  }
  
  required init?(coder aDecoder: NSCoder) {
      super.init(coder: aDecoder)
  }
  
  deinit {
      print("===) ChatKeyboard deinit.")
  }
  
  func loadContent() {
  
  backgroundColor = UIColor.white
  addSubview(buttonMic)
  }
  
  func loadConstrain() {
  
  buttonMic.snp.makeConstraints { (make) -&gt; Void in
             make.left.equalTo(micLeftPadding)
             make.top.equalTo(micTopPadding)
             make.width.equalTo(UIScreen.main.bounds.width*0.0581)
             make.height.equalTo(UIScreen.main.bounds.height*0.045)
  }
  }
  }
  
  
  class ChatroomViewController: UIViewController{
  
  weak var chatKeyboard:ChatKeyboard?
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      chatKeyboard = ChatKeyboard(frame: CGRect(x: 0, y: 0, width: 300, height: 44))
  }
  }
  </code></pre>
  
  <p>I set breakpoint at "chatKeyboard = ChatKeyboard(frame: CGRect(x: 0, y: 0, width: 300, height: 44))"and then my log print:<br></p>
  
  <pre><code>===) ChatKeyboard init.
  ===) ChatKeyboard deinit.
  </code></pre>