Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 单击TableViewCell以打开当前用户的纵断面图_Swift_Uitableview_Firebase_Firebase Realtime Database_Tableview - Fatal编程技术网

Swift 单击TableViewCell以打开当前用户的纵断面图

Swift 单击TableViewCell以打开当前用户的纵断面图,swift,uitableview,firebase,firebase-realtime-database,tableview,Swift,Uitableview,Firebase,Firebase Realtime Database,Tableview,我正在使用firebase数据库,在index path.row上有一个表视图,显示了用户的姓名、年龄、位置和图像。当将单元格单击到包含用户更多信息和照片的用户配置文件时,我将如何显示另一个视图。这是我的tableView的代码 override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return userList.count } overri

我正在使用firebase数据库,在index path.row上有一个表视图,显示了用户的姓名、年龄、位置和图像。当将单元格单击到包含用户更多信息和照片的用户配置文件时,我将如何显示另一个视图。这是我的tableView的代码

 override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return userList.count

}

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

    let cell = tableView.dequeueReusableCell(withIdentifier: "prefCell", for: indexPath) as! SFPTableViewCell

      let user = userList[indexPath.row]

    cell.name.text = userList[indexPath.row].name
    cell.location.text = userList[indexPath.row].location


    if let imageURL = user.image {

        cell.imageOne.loadImageUsingCacheWithUrlString(urlString: imageURL)
    }       
          return cell
}

    }

刚刚使用了
UITableViewDelegate
方法
“didSelectRowAtIndexPath”
并将图像及其索引发送到其他视图控制器

 override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let sb = UIStoryboard(name: "Main", bundle: nil)
        let detailVC = sb.instantiateViewController(withIdentifier: "ImageVC") as! DetailViewController
        detailVC.strImage  = self.arrImage[indexPath.row]
        self.navigationController?.pushViewController(detailVC, animated: true)
    }
DetailViewController
中取一个变量

var strImage : String = ""
并将此变量关联到UIImagView

 imgView.image = UIImage(named: strImage) 

使用代码使用didSelectRowAtIndexPath

使用故事板:

步骤1:选择tableview单元格

第2步:控制+单击鼠标并在目标视图中拖动

第三步:给任何一个segue

第四步:完成

在下面添加此代码

override  func tableView(_ tableView: UITableView, didSelectRowAtindexPath: IndexPath){

   let detailVC = storyboard.instantiateViewControllerWithIdentifier("MyDetailVC") as MyDetailVC // get the obect of other VC
   detailVC.myImage = <your_image> // assign your image which you wanted to send to other VC.
   self.navigationController?.pushViewController(detailVC,animated: true // Push to other VC
}
现在在
MyDetailVC.swift
中使用您的图像


您可以提出任何进一步的查询。

add tableview委托“DidSelectRowatineIndexPath”我可以通过电子邮件向您介绍我的查询吗?您是否可以从Web服务获取图像?
var myImage : UIImage? // Create variable of image type in required VC where you wanted to send data