How to get a navigation bar hight in iOS programatically
<p>I have to move up my view when <code>keyboardwillshown</code> then it back to it's normal place when keyboard will hide </p>

<p>Actually I have used this code on <code>viewdidload</code> method: </p>

<pre><code>override func viewDidLoad() { 

    NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillShow:"), name: UIKeyboardWillShowNotification, object: nil)
    NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillHide:"), name: UIKeyboardWillHideNotification, object: nil) 

}
</code></pre>

<p>Here is the method which I used for move up and down </p>

<pre><code>func keyboardWillShow(notification:NSNotification){ 

    print("keyboardwillshow")
    let keyboardSize = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.CGRectValue()

    self.view.frame = CGRectMake(0.0, -keyboardSize!.size.height + (self.navigationController?.navigationBar.frame.size.height)! + 20 , self.view.frame.size.width, self.view.frame.size.height )  

}

func keyboardWillHide(notification:NSNotification){

    self.view.frame = CGRectMake(0.0,(self.navigationController?.navigationBar.frame.size.height)!, self.view.frame.size.width, self.view.frame.size.height)
//  self.view.frame.origin.y += 350

}
</code></pre>

<p>While I run this program, it will show a run time error that is </p>

<blockquote>
  <p>unexpected found a nil while unwrapping </p>
</blockquote>

<p>Please help me fix this.</p>