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 } 

enter image description here

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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -