ios - Tableview button.tag throw lldb -
i don't know happen, set button.tag
table row , when reach row > 1, throw lldb. works if button.tag <= 1
func tableview(_ tableview: uitableview, cellforrowat indexpath: indexpath) -> uitableviewcell { let cell = tableview.dequeuereusablecell(withidentifier: "cells")! uitableviewcell let alertbtn = cell.viewwithtag(1) as! uibutton; alertbtn.tag = indexpath.row alertbtn.addtarget(self, action: selector(("showalert:")), for: uicontrolevents.touchupinside) return cell }
swift 3x...
you replacing tag first tag items getting nil replace code ...
func tableview(_ tableview: uitableview, cellforrowat indexpath: indexpath) -> uitableviewcell { let cell = tableview.dequeuereusablecell(withidentifier: "cells")! uitableviewcell let alertbtn = cell.viewwithtag(1) as! uibutton alertbtn.addtarget(self, action: #selcetor(showalert(sender:))), for: .touchupinside) return cell } func showalert(sender:uibutton) { let point = sender.convert(cgpoint.zero, to: self.tableview) let indexpath = self.tableview.indexpathforrow(at: point) }
Comments
Post a Comment