我不知道发生了什么,我设置了button.tag
与表行,当它到达行> 1,它会抛出LLDB。如果button.tag <= 1
泰伯维button.tag掷LLDB
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cells")! as UITableViewCell
let alertBtn = cell.viewWithTag(1) as! UIButton;
alertBtn.tag = indexPath.row
alertBtn.addTarget(self, action: Selector(("showAlert:")), for: UIControlEvents.touchUpInside)
return cell
}
它在哪里抛出error.can你告诉我们,showAlert的implemetation。 – luckyShubhra
错误来自于当我设置按钮标记时,即使我删除了添加目标,它仍然会抛出相同的错误。它与添加目标无关 –
你想让alertBtn = cell.viewWithTag(1)as做什么? UIButton的;线。这里你说的是带有标签1的视图就是你的按钮,然后你又想改变标签,所以在重用状态下你的标签会有所不同,并且可能的原因是这条线。为什么你想从标签中查看按钮? –