swift - Loading gif before adding cell in tableview -
i'm simulating chat , wanted know how show loading gif before message bubble added in tableview.
add message function:
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) } }
Comments
Post a Comment