     
     //MARK: textview del
     
-    func textView(textView:UITextView, shouldChangeTextInRange range:NSRange, replacementText text:String) -> Bool
+    func textViewDidBeginEditing(textView:UITextView)
     {
-        let currentText:NSString = NSString(string:textView.text)
-        let newText:String = currentText.stringByReplacingCharactersInRange(range, withString:text)
-        heightForText(newText)
-        
-        return true
+        heightForText()
+    }
+    
+    func textViewDidEndEditing(textView:UITextView)
+    {
+        heightForText()
+    }
+    
+    func textViewDidChange(textView:UITextView)
+    {
+        heightForText()
     }
 }
                    { [weak self] in
                        
                        self?.field.text = self?.kEmpty
                        
                        if self != nil
                        {
                            self!.heightForText(self!.kEmpty)
                        }
                    }
                }
            }
        }
    }
    
    private func heightForText(text:String)
    {
        let newHeight:CGFloat
        let nsString:NSString = NSString(string:text)
        let attributes:[String:AnyObject] = field.typingAttributes
        let size:CGSize = CGSizeMake(field.bounds.maxX, kHypoteticalMaxHeight)
        let rect:CGRect = nsString.boundingRectWithSize(
            size,
            options:stringDrawingOptions,
            attributes:attributes,
            context:nil)
        let height:CGFloat = ceil(rect.maxY) + marginField
        
        if height > kMaxHeight
        {

    
    init(controller:CChat)
    {
        super.init(frame:CGRectZero)
        clipsToBounds = true
        translatesAutoresizingMaskIntoConstraints = false
