swift - 如何使 UIImageView 全屏显示(Swift)

标签 swift uitableview uiimageview

我在 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) {



}

最佳答案

您必须创建一个自定义TableviewCell,其中有一个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 
}

关于swift - 如何使 UIImageView 全屏显示(Swift),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31736131/

相关文章:

ios - 如何在 MapKit 上绘制围绕多个注释/坐标的圆形叠加层?

ios - 为 UITableView 中的每个单元格提供一个数字

objective-c - UIAppearance 对 Label 文本颜色没有影响

ios - Swift:实现可拖动的 UIImageView 需要哪些方法?

ios - 将两个 UIView 合并为一个 UIImage

ios - 如何在swift中的动态tableview中创建动态tableview?

ios - 'screen' 的 Setter 在 iOS 13.0 中被弃用

ios - 嵌入到 UIViewController 中的 Container 时切断 UITableViewController

ios - 在 UITableViewCell 中选择特定索引后在 safari 中打开链接

iOS:使用全屏图像显示模态视图 Controller