ios - How to add custom view to JSQMessagesViewController cell so that it includes one view with some buttons and text view? -
i using https://github.com/jessesquires/jsqmessagesviewcontroller/issues/1820 library chat application. using libary able send images , video, app needs send 1 view button , text. when user sends text appear others text , button , when clicks button 1 push notification generated. not able figure out how can achieve this.
here screen shot how want custom view be. has text user has typed , has 2 button accept , reject.
i suggest create own custom view this. can use jsqincomingcollectionviewcell.xib
or jsqoutgoingcollectionviewcell.xib
template self.
- copy them example project , paste them own
- rename files else
cellwithconfimationbuttons
in chatviewcontroller i.e. ever called view subclass of 'jsqmessagesviewcontroller'. add these 2 lines
self.collectionview.registernib(uinib(nibname: "cellwithconfimationbuttons", bundle: nil), forcellwithreuseidentifier: "incomingcell") self.collectionview.registernib(uinib(nibname: "cellwithconfimationbuttons", bundle: nil), forcellwithreuseidentifier: "outgoingcell")
add constraints lays self out right.
set images , need make files support guy.
jsqmessagescollectionviewcelloutgoing.m
,jsqmessagescollectionviewcelloutgoing.h
need addiboutlets
buttons , add actions , logic in file
then need set flag or way of determining message type of message buttons.
- then in
collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath)
you check flag , cell
if message.flag == true let cell = collectionview.dequeablecellwithidentifier("incomingcell")
then set up.
i hope helps. let me know if can more. 😜
Comments
Post a Comment