I am trying to dismiss keyboard in text view using accessory views with done button but keyboard is not showing done button in it.Actually i have writen my code in textViewDidBeginEditing using inputAccessoryView.Here is my code.
func textViewDidBeginEditing(textView: UITextView) { currentTextView = textView //This is to tell the current position in text view
    var indexPath:NSIndexPath = NSIndexPath(forRow: 0, inSection: 2)
    let cell:EventTableTableViewCell = EventTableview.cellForRowAtIndexPath(indexPath) as! EventTableTableViewCell
    cell.messageTextView.autocorrectionType = UITextAutocorrectionType.No
    let keyboardDoneButton = UIToolbar()
    keyboardDoneButton.sizeToFit()
    let item = UIBarButtonItem(title: "Done", style: UIBarButtonItemStyle.Plain, target: self, action: Selector("doneButton"))
    var toolbarButtons = [item]
    //Put the buttons into the ToolBar and display the tool bar
    keyboardDoneButton.setItems(toolbarButtons, animated: false)
        keyboardDoneButton.userInteractionEnabled = true
//cell.messageTextView.inputAccessoryView = keyboardDoneButton
    textView.inputAccessoryView = keyboardDoneButton
    }
}
func doneButton()
{
UIApplication.sharedApplication().sendAction("resignFirstResponder", to:nil, from:nil, forEvent:nil)
}