简体   繁体   中英

how to add popover segue from UITableViewCell button click in swift 3.0?

Here i am using popover to a new ViewController from my UITableVIewCell button click but i am getting this error Main.storyboard: Couldn't compile connection: property=anchorView destination=>

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    if(tableView == self.table_view_one) {
        var cell  = table_view_one.dequeueReusableCell(withIdentifier: "first_cell", for: indexPath) as! first_cell
       cell.first_view_time_btn.addTarget(self, action: #selector(Iop_gonio_ViewController.someAction), for: .touchUpInside)
       return cell
    }
}

func someAction() {
    self.performSegue(withIdentifier: "first_time_btn", sender: self)
}

try

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if(tableView == self.table_view_one) {
    var cell  = table_view_one.dequeueReusableCell(withIdentifier: "first_cell", for: indexPath) as! first_cell
   cell.first_view_time_btn.addTarget(self, action: #selector(someAction(sender:)), for: .touchUpInside)
   return cell
}

func someAction(sender:UIButton) {
    self.performSegue(withIdentifier: "first_time_btn", sender: self)
}

But I don't think it is a nice method, you should create a protocol handling such interaction.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM