ios - Custom Edit Buttons to Segmented Control TableViews -


i have tableviewcontroller segmentedcontrol. works great, data show suppose on each tableview , can switch between each segment control.

i add swipe delete feature each segmentcontrol's tableview. want segment1 have 1 button, , segment2 have 2 buttons.

ex:

segment 1   button: more segment 2   button: more   button: delete 

how can this, @ moment keep getting blank space on segment1 crashes app when clicked. there anyway hide blank space/button segment1?

override func tableview(tableview: uitableview, editingstyleforrowatindexpath        indexpath: nsindexpath) -> uitableviewcelleditingstyle {      var table:uitableviewcelleditingstyle = uitableviewcelleditingstyle.none      switch (self.segmentcontrol.selectedsegmentindex) {     case 0:         table = uitableviewcelleditingstyle.delete     case 1:         table = uitableviewcelleditingstyle.delete     default:         break     }      return table  }  override func tableview(tableview: uitableview, editactionsforrowatindexpath  indexpath: nsindexpath) -> [anyobject]? {      var morerowaction = uitableviewrowaction()     var deleterowaction = uitableviewrowaction()      switch (self.segmentcontrol.selectedsegmentindex) {     case 0:         morerowaction = uitableviewrowaction(style: uitableviewrowactionstyle.default, title: "more", handler:{action, indexpath in             println("more•action");         });      case 1:         morerowaction = uitableviewrowaction(style: uitableviewrowactionstyle.default, title: "more", handler:{action, indexpath in             println("more•action");         });         morerowaction.backgroundcolor = uicolor(red: 0.298, green: 0.851, blue: 0.3922, alpha: 1.0);          deleterowaction = uitableviewrowaction(style: uitableviewrowactionstyle.default, title: "delete", handler:{action, indexpath in             println("delete•action");         });     default:         break     }      return [deleterowaction, morerowaction]; } 

return 1 uitableviewrowaction in case 0,return 2 uitableviewrowaction in case 1, try this

override func tableview(tableview: uitableview, editactionsforrowatindexpath indexpath: nsindexpath) -> [anyobject]? {      var morerowaction = uitableviewrowaction()     var deleterowaction = uitableviewrowaction()      switch (self.segmentcontrol.selectedsegmentindex) {     case 0:         morerowaction = uitableviewrowaction(style: uitableviewrowactionstyle.default, title: "more", handler:{action, indexpath in             println("more•action");         });         return [morerowaction];     case 1:         morerowaction = uitableviewrowaction(style: uitableviewrowactionstyle.default, title: "more", handler:{action, indexpath in             println("more•action");     });         morerowaction.backgroundcolor = uicolor(red: 0.298, green: 0.851, blue: 0.3922, alpha: 1.0);          deleterowaction = uitableviewrowaction(style: uitableviewrowactionstyle.default, title: "delete", handler:{action, indexpath in             println("delete•action");         });         return [deleterowaction, morerowaction];     default:         break     }      return [deleterowaction, morerowaction]; } 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -