gpt4 book ai didi

ios - 从 Objective-C 的 View Controller 中的类方法访问 ViewController 本身

转载 作者:行者123 更新时间:2023-11-28 22:06:55 27 4
gpt4 key购买 nike

我的项目中有一个 ViewController,它有一个将文件上传到服务器的类方法。它是类方法,因为它将被处理图像捕获的 NSObject 类访问。

但是,事实证明,我无法从原始 ViewController 中的静态函数内部访问 ViewController 本身。我想这样做是为了显示一个覆盖在 ViewController 上的进度 HUD。

关于如何处理这个的任何想法?

该方法在 header 中这样定义:

+(void)uploadImage:(NSString*)imagePath thumbnailPath:(NSString*)thumbnailPath;

最佳答案

这里有几个选项:

1) 将方法设为实例方法,并让 NSObject 在 View Controller 的特定实例上调用它。

2) 在类方法中发布通知并让您的 View Controller 实例订阅它。

关于ios - 从 Objective-C 的 View Controller 中的类方法访问 ViewController 本身,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23750337/

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