Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.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
如何使UIImageView全屏显示(Swift)_Swift_Uitableview_Uiimageview - Fatal编程技术网

如何使UIImageView全屏显示(Swift)

如何使UIImageView全屏显示(Swift),swift,uitableview,uiimageview,Swift,Uitableview,Uiimageview,我在UITableViewCell中有一个UIImageView。点击图像时,我希望图像全屏显示。我需要在代码中添加什么 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let tapRecognizer = UITapGestureRecognizer(target: self, action: "makeLarg

我在UITableViewCell中有一个UIImageView。点击图像时,我希望图像全屏显示。我需要在代码中添加什么

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {


    let tapRecognizer = UITapGestureRecognizer(target: self, action: "makeLarger")
    cell.itemImage.addGestureRecognizer(tapRecognizer)


    return cell
}


func makeLarger(gesture: UIGestureRecognizer) {



}

您必须创建一个customTableviewCell,其中有一个ImageView IBOutlet,然后在viewDidLoad()中附加数据数组

 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
 var cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! CustomTableViewCell

    var images = self.data[indexPath.row]
    cell.imageview.image = UIImage(named: images)
    cell.imageview.userInteractionEnabled = true
    cell.imageview.multipleTouchEnabled = true
    var tapgesture = UITapGestureRecognizer(target: self, action: Selector("tap"))
    tapgesture.numberOfTapsRequired = 1
    cell.addGestureRecognizer(tapgesture)

    return cell
}

func tap(){

 print("tap")
// then you should pass the single image to the DestinationViewController 
}

此代码使您的imageView全屏显示:

let screenSize: CGRect = UIScreen.mainScreen().bounds
let screenWidth = screenSize.width
let screenHeight = screenSize.height
imageView.frame = CGRect(x: 0, y: 0, width: screenWidth, height: screenHeight)
它看起来像这样(在我点击按钮后,图像变成了全屏)

您现在没有任何代码,您在我的朋友中传递的数据在哪里我在cellForRowAtIndexPath中创建了一个点击手势,然后创建了动作函数makeBiger。你能告诉我哪里错了吗?欣赏它。我认为这张图片有问题,因为用这种方式,如果你在单元格中点击一张图片,你无法选择要显示的图片