ios - Error using JSQMessagesViewController -
trying make chat app on iphone , i've problem when integrating jsqmessagesviewcontroller
.
here full page code of "conversationviewcontroller"
import uikit import jsqmessagesviewcontroller class conversationviewcontroller : jsqmessagesviewcontroller { var myindexpath:int! let outgoingbubble = jsqmessagesbubbleimagefactory().outgoingmessagesbubbleimagewithcolor(uicolor(red: 63/255, green: 173/255, blue: 169/255, alpha: 1.0)) let incomingbubble = jsqmessagesbubbleimagefactory().incomingmessagesbubbleimagewithcolor(uicolor(red: 230/255, green: 231/255, blue: 236/255, alpha: 1.0)) var messages = [jsqmessage]() override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. self.setup() self.adddemomessages() self.navigationitem.title = "\(myindexpath)" } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } func reloadmessagesview() { self.collectionview?.reloaddata() } } //mark - setup extension conversationviewcontroller { func adddemomessages() { in 1...3 { let sender = (i%2 == 0) ? "server" : self.senderid let messagecontent = "et eodem impetu domitianum praecipitem per scalas itidem funibus constrinxerunt. \(i)" let message = jsqmessage(senderid: sender, displayname: sender, text: messagecontent) self.messages += [message] } self.reloadmessagesview() } func setup() { self.senderid = uidevice.currentdevice().identifierforvendor?.uuidstring self.senderdisplayname = uidevice.currentdevice().identifierforvendor?.uuidstring } } //mark - data source extension conversationviewcontroller { override func collectionview(collectionview: uicollectionview, numberofitemsinsection section: int) -> int { return self.messages.count } override func collectionview(collectionview: jsqmessagescollectionview!, messagedataforitematindexpath indexpath: nsindexpath!) -> jsqmessagedata! { let data = self.messages[indexpath.row] return data } override func collectionview(collectionview: jsqmessagescollectionview!, diddeletemessageatindexpath indexpath: nsindexpath!) { self.messages.removeatindex(indexpath.row) } // sender type bubble override func collectionview(collectionview: jsqmessagescollectionview!, messagebubbleimagedataforitematindexpath indexpath: nsindexpath!) -> jsqmessagebubbleimagedatasource! { let data = messages[indexpath.row] switch(data.senderid) { case self.senderid: return self.outgoingbubble default: return self.incomingbubble } } // cell text color override func collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath) -> uicollectionviewcell { let cell = super.collectionview(collectionview, cellforitematindexpath: indexpath) as! jsqmessagescollectionviewcell let message = messages[indexpath.item] if message.senderid == "server" { cell.textview!.textcolor = uicolor.blackcolor() } else { cell.textview!.textcolor = uicolor.whitecolor() } return cell } }
and cause following error:
terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'error: required method not implemented: -[jsqmessagesviewcontroller collectionview:avatarimagedataforitematindexpath:]
can me please? thanks
it required need override , pass nil.
override func collectionview(collectionview: jsqmessagescollectionview!, avatarimagedataforitematindexpath indexpath: nsindexpath!) -> jsqmessageavatarimagedatasource? { return nil }
you can add same file. should good.
Comments
Post a Comment