gpt4 book ai didi

ios - Xcode - 图像在用户选择后未出现在 UIImageView 中

转载 作者:行者123 更新时间:2023-11-28 06:18:12 25 4
gpt4 key购买 nike

我正在尝试制作一个应用程序,您可以在其中“撰写”假推文,但我的代码似乎没有将用户选择的图像添加到我为 Twitter 个人资料图片设置的 UIImageView。

class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate{    
@IBOutlet weak var twitterName: UILabel!
@IBOutlet weak var twitterUsername: UILabel!
@IBOutlet weak var twitterProfilePic: UIImageView!
@IBOutlet weak var twitterTweet: UILabel!
@IBOutlet weak var inputTwitterName: UITextField!
@IBOutlet weak var inputTwitterUsername: UITextField!
@IBOutlet weak var inputTweet: UITextField!
@IBAction func chooseTwitterImage(_ sender: Any) {

let profilePic = UIImagePickerController()
profilePic.delegate = self
profilePic.sourceType = UIImagePickerControllerSourceType.photoLibrary
profilePic.allowsEditing = false
self.present(profilePic, animated: true)
}

@IBAction func makeTweetButton(_ sender: Any) {
twitterName.text = (inputTwitterName.text)!
twitterUsername.text = (inputTwitterUsername.text)!
twitterTweet.text = (inputTweet.text)!

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
if let profilePic = info[UIImagePickerControllerOriginalImage] as? UIImage
{
twitterProfilePic.image = profilePic
}
else
{
print("ERROR PICKING IMAGE")
}
}
}

它似乎对 UIImageView 没有任何影响...帮助。

最佳答案

didFinishPickingMediaWithInfo 嵌套方法移动到 ViewController 的类中可以解决问题。

关于ios - Xcode - 图像在用户选择后未出现在 UIImageView 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44475894/

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