Я могу перенаправить всю строку на ссылку из API, используя:
Код: Выделить всё
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let item = page!.tradeshows[indexPath.row]
if let eventURLS = item.url {
UIApplication.sharedApplication().openURL(eventURLS, options: [:], completionHandler: nil)
} else {print("link not working")
}
}
Я также пробовал:
Код: Выделить всё
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) - > UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "eventCell",
for: indexPath) as!EventTableViewCell
let item = page!.tradeshows[indexPath.row]
cell.registerButton.addTarget(self, action: #selector(UpcomingEventsViewController.onClickedRegistrationButton(_: )),
for: .touchUpInside)
cell.registerButton.tag = indexPath.row
return cell
}
@objc func onClickedRegistrationButton(_ button: UIButton) {
let buttonLink = button.tag
}
Подробнее здесь: https://stackoverflow.com/questions/588 ... leviewcell