gpt4 book ai didi

swift - 为弹出窗口设置 UIImageView

转载 作者:行者123 更新时间:2023-11-30 13:12:06 29 4
gpt4 key购买 nike

这个被调用的函数调用一个名为 PopupViewController 的 View Controller 来填充屏幕:

func callSavedPopup() {
let popupViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("PopupViewController") as! PopupViewController
self.addChildViewController(popupViewController)
popupViewController.view.frame = self.view.bounds

popupViewController.userChoiceImage = UIImageView(image: UIImage(named: "CheckMark.png"))

popupViewController.userChoiceLabel.text = "Congrats! Your run was saved!"
self.view.addSubview(popupViewController.view)
popupViewController.didMoveToParentViewController(self)
}

在 PopupViewController.swift 中,有一个图像的导出:

@IBOutlet weak var userChoiceImage: UIImageView!

如何让 userChoiceImage 保存顶部函数中标题为“CheckMark.png”的图像。他们分属两个不同的类(class)

最佳答案

1.) 确保文件名 (CheckMark.png) 的拼写正确! :-)

2.) 确保 Storyboard上默认情况下没有隐藏 socket 。

3.) 确保您的图像已正确连接到 socket (Ctrl + 拖动)

4.)而不是这样做:

 popupViewController.userChoiceImage = UIImageView(image: UIImage(named: "CheckMark.png"))

尝试以下操作:

popupViewController.userChoiceImage.image = UIImage(named: "CheckMark.png")

这样你就可以保持 ImageView 的大小、位置等。

关于swift - 为弹出窗口设置 UIImageView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38622055/

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