我希望弹出用户的图像(没有操作选项),然后在外面触摸时将其关闭。
假设表格视图由 2 个 UI 元素(一个按钮和一个文本)和一张图片组成。您将如何设置仅为图片的弹出上下文菜单 - immy?
public override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! ViewControllerTableViewCell
let immy = cell.viewWithTag(1) as! UIImageView
let person: Userx = people[indexPath.row]
let button = cell.viewWithTag(3) as! UIButton
cell.lblName.text = person.Education
cell.postID = self.people[indexPath.row].postID
if let PhotoPosts = person.PhotoPosts {
let url = URL(string: PhotoPosts)
print(PhotoPosts, "sttdb")
immy.sd_setImage(with: url)
}
return cell
}
extension homepage {
func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? {
let configuration = UIContextMenuConfiguration(identifier: nil, previewProvider: nil)
return configuration
}
}
下面是在第一条评论之后添加的 ViewControlleTableViewCell。我对评论的回复还解释了它在 main.storyboard 中的外观。
class ViewControllerTableViewCell: UITableViewCell {
@IBOutlet weak var button: UIButton!
@IBOutlet weak var immy: UIImageView!
@IBOutlet weak var lblgenre1: UILabel!
@IBOutlet weak var lblName: UILabel!
@IBOutlet weak var lblName1: UILabel!
@IBOutlet weak var likeLabel: UILabel!
var postID: String!
var caption1: String!
var keyToPost: String!
var latestLocation1: [String: Double]?
let databaseRef = Database.database().reference()
var refArtists: DatabaseReference!
let profileImageView: UIImageView = {
let imageView = UIImageView()
return imageView
} ()
override func awakeFromNib() {
super.awakeFromNib()
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
@IBAction func button1(_ sender: Any) {
}
@IBAction func button2NBTHISISTORPREVENTSEGUE(_ sender: Any) {
}
}
在主页中:
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! ViewControllerTableViewCell