gpt4 book ai didi

ios - 点击时在 TableView 中为 ImageView 创建 subview 覆盖

转载 作者:搜寻专家 更新时间:2023-11-01 06:44:49 25 4
gpt4 key购买 nike

我想创建一个在 UITableView 上弹出的 subview ,其中包含全屏 cell 上的 UIImageView 图像在右上角有一个退出按钮,在另一个 cellUITextView 底部有 cellUITextView >

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(reuseIdentifier, forIndexPath: indexPath) as! TalesTableViewCell let tapGesture = UITapGestureRecognizer(target: self, action: "imageTapped:")

cell.tableImage.addGestureRecognizer(tapGesture)

cell.tableImage.userInteractionEnabled = true

return cell
}

func imageTapped(gesture: UIGestureRecognizer) {

//Code here I think

}

有什么想法吗?谢谢!

最佳答案

使用下面的代码..

func imageTapped(gesture: UIGestureRecognizer) {

var overlay : UIView = UIView(frame: CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height))

var imageView : UIImageView = UIImageView(image: (gesture.view as! UIImageView).image) // This includes your image in table view cell

imageView.frame = CGRectMake(0, 0, 0, 0) // set up according to your requirements

var doneBtn : UIButton = UIButton(frame: CGRectMake(0, 0, 0, 0)) // set up according to your requirements
doneBtn.addTarget(self, action: "pressed:", forControlEvents: .TouchUpInside)

overlay.addSubview(imageView)
overlay.addSubview(doneBtn)

self.view.addSubview(overlay)
}

func pressed(sender: UIButton!) {

sender.superview?.removeFromSuperview()
}

关于ios - 点击时在 TableView 中为 ImageView 创建 subview 覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31576513/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com