我正在模拟聊天,我想知道如何在tableview中添加消息泡泡之前显示加载gif。
添加留言功能:
func addMessage() {
var message: iMessage
message = iMessage.initIMessageWithName(self.name, message: self.text, time:self.currentHour(), type "self")
self.updateTableView(message)
}
updateTableView:
func updateTableView(msg: AnyObject) {
self.chatTable!.beginUpdates()
let row1 NSIndexPath = NSIndexPath(forRow: currentMessages!.count, inSection: 0)
currentMessages!.insertObject(msg, atIndex: currentMessages!.count)
self.chatTable!.insertRowAtIndexPaths(NSArray(objects: row1) as! [NSIndexPath], withRowAnimation: UITableViewRowAnimation.Bottom)
self.chatTable!.endUpdates()
if self.chatTable!.numberOfRowsInSection(0) != 0 {
let ip: NSIndexPath = NSIndexPath(forRow: self.chatTable!.numberOfRowsInSection(0)-1, inSection: 0)
chatTable?.scrollToRowIndexPath(ip, atScrollPosition:UITableViewScrollPosition.Bottom, animated: true)
}
}