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.

enter image description here

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.

  1. copy them example project , paste them own
  2. rename files else cellwithconfimationbuttons
  3. 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")

  4. now can add buttons xib files xib buttons

  5. add constraints lays self out right.

  6. set images , need make files support guy. jsqmessagescollectionviewcelloutgoing.m , jsqmessagescollectionviewcelloutgoing.h need add iboutlets buttons , add actions , logic in file

then need set flag or way of determining message type of message buttons.

  1. 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

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -