swift3 selector传递参数问题

问与答 · tangyunfei · 发布于 1 年前 · 1658 次阅读

var index = 12 let pan = #selector(self.delimg( index : ) ) let guest = UITapGestureRecognizer(target: self, action: pan)

func delimg(index : Int){ print("(index)") }

这样为什么拿不到参数 需要怎么操作

共收到 1 条回复
zhiliang729 · #1 · 1 年前

var index = 12 let pan = #selector(delimg( index : ) ) let guest = UITapGestureRecognizer(target: self, action: pan)

func delimg(index : Int){ print("(index)") }

let pan = #selector(delimg( index : ) ) 不能加self.

回帖