Swift: Pass UITableViewCell label to new ViewController

后端 未结 4 1317
难免孤独
难免孤独 2020-12-01 03:23

I have a UITableView that populates Cells with data based on a JSON call. like so:

var items = [\"Loading...\"]
var indexValue = 0

// Here is SwiftyJSON co         


        
4条回答
  •  鱼传尺愫
    2020-12-01 03:54

    I do it like this.

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    
     let selectedName = nameArray[indexPath.row]      
    
    let newView: nextViewName = self.storyboard?.instantiateViewController(withIdentifier: "nextViewName") as! nextViewName
    
       newView.label.text = selectedValue
       self.present(newView, animated: true, completion: nil)
    
    
    
    }
    

提交回复
热议问题