【发布时间】:2018-09-26 20:30:22
【问题描述】:
所以我有这个按钮的功能代码
@objc func facebookButtonPressed(_ urlString : String)
{
let url = URL(string: urlString)!;
let safariViewController = SFSafariViewController(url: url);
self.present(safariViewController, animated: true,completion: nil);
}
我将此功能附加到我的按钮上
cell.facebookButton.addTarget(cell.facebookButton, action: #selector(facebookButtonPressed(_:facebookHandles[0])), for: UIControlEvents.touchUpInside);
facebookHandles 看起来是这样的:
let facebookHandles = ["https://www.facebook.com/harsh.mutha.902","https://www.facebook.com/skvrahul?fb_dtsg_ag=AdzxdqYcNvlFjd6QcX6a2sTXKagTQsR_OCuyHLe8z8gPug%3AAdxQz3YDUQ3tL-a7ME_0Owzu-02FSL0SO7VWqcJ_CpPUrw","https://www.facebook.com/saptarshi.roychaudhuri?fb_dtsg_ag=AdzxdqYcNvlFjd6QcX6a2sTXKagTQsR_OCuyHLe8z8gPug%3AAdxQz3YDUQ3tL-a7ME_0Owzu-02FSL0SO7VWqcJ_CpPUrw"];
为什么会出现这个错误,我该如何解决?
Argument of '#selector' does not refer to an '@objc' method, property, or initializer
collection view where the buttons are
从图片中可以看出,每个单元格的集合视图中有多个按钮。 现在,当单击该开发人员单元格的 facebook 按钮时,如何为开发人员适当地打开 facebook 页面??
【问题讨论】:
-
您不能通过操作传递自定义参数,这是不可能的。要么不传递参数,要么传递受影响的 UI 元素和事件,仅此而已。