tableview disappears when typing was being done in textfield and app goes to background and becomes active again

I have made a tableView Controller embedded in Navigation controller using story board. It is like a Chat application UI. I load data from sqlite database. There is a NSMutableArray in which i load data to display on UI. Also there is a text field to type message.
http://i.stack.imgur.com/yNb9q.png


Here is the UI:

http://i.stack.imgur.com/kyX89.jpg

When we start typing, we show keyboard. If we press "Home" button and go in background. Then when we come back, table view disappears. No data is shown. It shows blank page with keyboard:

https://cloud.githubusercontent.com/assets/5336012/16971538/9280fb14-4dd9-11e6-967f-c06fbb128d32.png

Here is my code:


var messages:NSMutableArray! 

override func viewDidLoad() { super.viewDidLoad() 
messages = NSMutableArray()
}

func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
  var cell : UITableViewCell!var messageDic = messages.objectAtIndex(indexPath.row) as! [String : String];
 NSLog(messageDic["message"]!, 1) l
et msgType = messageDic["type"] as NSString!
 let msg = messageDic["message"] as NSString! l
et date2=messageDic["date"] as NSString! 
let sizeOFStr = self.getSizeOfString(msg) 
if (msgType.isEqualToString("1"))
{ cell = tblForChats.dequeueReusableCellWithIdentifier("ChatSentCell")! as UITableViewCell 
let textLable = cell.viewWithTag(12) as! UILabel 
let chatImage = cell.viewWithTag(1) as! UIImageView 
let profileImage = cell.viewWithTag(2) as! UIImageView 
let timeLabel = cell.viewWithTag(11) as! UILabel 
chatImage.frame = CGRectMake(chatImage.frame.origin.x, chatImage.frame.origin.y, ((sizeOFStr.width + 100) > 200 ? (sizeOFStr.width + 100) :
 200), sizeOFStr.height + 40) 
chatImage.image = UIImage(named: "chat_receive")?.stretchableImageWithLeftCapWidth(40,topCapHeight: 20); 
extLable.frame = CGRectMake(textLable.frame.origin.x, textLable.frame.origin.y, textLable.frame.size.width, sizeOFStr.height)
profileImage.center = CGPointMake(profileImage.center.x, textLable.frame.origin.y + textLable.frame.size.height - profileImage.frame.size.height/2+20) 
textLable.text = "\(msg)"}}


Please help why data is not loaded when app comes to foreground again.

tableview disappears when typing was being done in textfield and app goes to background and becomes active again
 
 
Q