gpt4 book ai didi

ios - 选择图像后如何执行 Segue

转载 作者:行者123 更新时间:2023-11-28 05:43:33 25 4
gpt4 key购买 nike

我想在用户选择图像(通过单击 ImageView )后立即执行 segue。

我已经检查了 segue id 并成功连接了两个 View Controller 。

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
// Executed when we select an image from the photo library.
if let image = info[UIImagePickerControllerOriginalImage] as? UIImage {

// Sets the image to the image view (not really relevant because
// we push the user to the DetailVC, but let's leave it).
self.imageView.image = image

// Closing the image picker.
self.dismiss(animated: true, completion: nil)

// Performing segue (It doesn't perform!).
print("It gets to this point, but doesn't perform.")
self.performSegue(withIdentifier: "showDetail", sender: nil)
}
}

程序将图像设置为 ImageView ,在“执行”函数之后获取打印语句,但不执行转场。

最佳答案

在 Storyboard中选择具有 ImageView 的 View Controller ,在顶部有黄色圆圈右键单击从那里拖动到您要转至的 View Controller 并为其标识符指定一个 ID =“segueID”然后像这样编辑你的 didfinishpicking 方法

if let img = info[.originalImage] as? uiimage{
myimageview.image = img
dismiss(animated: true) {
self.performSegue(withIdentifier: “segueID”, sender: self)}}

关于ios - 选择图像后如何执行 Segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55715291/

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