gpt4 book ai didi

swift popToViewController

转载 作者:IT王子 更新时间:2023-10-29 05:29:17 25 4
gpt4 key购买 nike

大家好,我正在学习 Swift,在这里需要一些帮助。

用户正在注册并选择了他们的图片。关闭图像选择器后,我想让 ComposeViewController 出现。

代码如下:

func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: NSDictionary!) {
let pickedImage:UIImage = info.objectForKey(UIImagePickerControllerOriginalImage) as UIImage

//Scale Down Image
let scaledImage = self.scaleImageWith(pickedImage, and: CGSizeMake(100,100))

let imageData = UIImagePNGRepresentation(scaledImage)

let imageFile:PFFile = PFFile(data: imageData)

PFUser.currentUser().setObject(imageFile, forKey: "profileImage")
PFUser.currentUser().saveInBackgroundWithTarget(nil, selector: nil)

picker.dismissViewControllerAnimated(true, completion: nil)

//this is the line seems to have problem.
self.navigationController?.popToViewController(ComposeViewController, animated: true)
}

然后我得到了这些错误:ComposeViewController.Type' 不可转换为 'UIViewController类型名称后预期的成员名称或构造函数调用

它建议通过在 ComposeViewController 之后放置 () 来修复,但修复后它会给出更多错误。

希望有人能提供帮助。谢谢! :-)

最佳答案

let controllers = self.navigationController?.viewControllers
for vc in controllers! {
if vc is YourVC {
_ = self.navigationController?.popToViewController(vc as! YourVC, animated: true)
}
}

关于 swift popToViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28190070/

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