テーブルビューのセルでは、私は2つのボタンが1つを受け入れるために拒否する必要があります。テーブルビューのセル内のボタン
UITableViewCellでは、両方のボタンのIBOutletを接続しました。 私は減少傾向にタップすると、私は受け入れる上でタップすると、それは、functions-衰退の両方を呼び出し、受け入れるXcodeで、私は2に減少タグを設定しているとのViewController
func accept(_ sender: UIButton){
let buttonTag = sender.tag
let point = sender.convert(CGPoint.zero, to: friendRequestTableView as UIView)
let indexPath: IndexPath! = followerReqTableView.indexPathForRow(at: point)
let user = requestsArray[indexPath.row]
func decline(_ sender: UIButton){
let buttonTag = sender.tag
let point = sender.convert(CGPoint.zero, to: friendRequestTableView as UIView)
let indexPath: IndexPath! = followerReqTableView.indexPathForRow(at: point)
let user = requestsArray[indexPath.row]
}
func tableView(_ tableView:UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = friendRequestTableView.dequeueReusableCell(withIdentifier: "FriendRequestTableViewCell") as? FriendRequestTableViewCell else { return UITableViewCell() }
let user = requestsArray[indexPath.row]
let image = cell.viewWithTag(1) as! UIImageView
cell.confCell(///some user details)
cell.decline.tag = 2
cell.accept.tag = 3
cell.decline.addTarget(self, action:#selector(self.decline(_:)), for: .touchUpInside)
cell.decline.addTarget(self, action:#selector(self.accept(_:)), for: .touchUpInside)
return cell
}
内部3.
にタグを受け入れますそれは何もしません。 どこが間違っていますか?
もちろんです:両方のアクションを同じボタンに2回追加します.2回は 'cell.decline.addTarget'です。 – vadian
ああああああ@vadian –