将信息从 UIActionSheet 传递给委托

发布于 2024-09-18 23:20:51 字数 553 浏览 6 评论 0原文

我对将数据传递回委托的理解完全围绕着创建一个新的视图控制器并使其符合协议。

我试图从使用 UIDatePickerModeCountDownTimer 模式设置的 UIDatePicker 获取时间输入,但遇到了问题。

在 Main1.m 内部,我创建了一个 UIActionSheet *action,并设置了所有内容,以便单击时它会显示一个 UIDatePicker。在 Main.m 内部我还说:

main.delegate = self;

如果这不是 UIActionSheet,我会在新的 ViewController 中进行协议引用,然后让新的 vc 将数据传递给 Main 具有的方法,但我不能用UI操作表!!

我缺少什么?我认为操作表有本质上的不同,但我无法弄清楚。

感谢您的帮助!!!

编辑:

抱歉!我为我的视图控制器指定了一个通用名称。它实际上不是 Main.m,而是 FirstViewController.h/m

我没有意识到我的通用引用与与 vc 完全不同的 Main.m 文件混淆了。

My understanding about passing data back to a delegate completely revolves around making a new view controller and having it conform to a protocol.

I am trying to get a time input back from a UIDatePicker set with the UIDatePickerModeCountDownTimer mode and I am running into issues.

Inside of Main1.m I create a UIActionSheet *action, and set everything up so that it presents itself with a UIDatePicker on a click. Inside of Main.m I also say:

main.delegate = self;

If this were not a UIActionSheet, I would make a protocol reference inside the new ViewController and then have the new vc pass data to a method that Main has, but I can't do that with a UIActionSheet!!

What am I missing? I assume there is something inherently different about Action Sheets, ut I can't figure it out.

Thanks for your help!!!

EDIT:

Sorry! I was giving a generic name to my view controller. It isn't actually Main.m, its FirstViewController.h/m

I didn't realize that my generic reference was getting mixed up with the Main.m file that is completely different than a vc.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

裸钻 2024-09-25 23:20:51

我不太明白为什么你要把你的委托任务放在 Main.m 中。我假设您正在 ViewController 中设置 UIActionSheet,并从那里启动它。在这种情况下,您的 ViewController 是您的委托对象。因此,您需要确保您的 ViewController 实现了 UIActionSheetDelegate。即:

@interface SomeController : UIViewController <UIActionSheetDelegate> 

然后您只需在视图控制器类中实现该委托所需的方法,就可以了。如果我遗漏了有关如何实现此功能的信息,那么您需要提供更多代码示例来检查。

I don't exactly understand why you're putting your delegate assignment in Main.m. I assume that you're setting up your UIActionSheet in a ViewController, and launching it from there. In this case, your ViewController is your delegate object. So you need to make sure that your ViewController implements the UIActionSheetDelegate. ie:

@interface SomeController : UIViewController <UIActionSheetDelegate> 

Then you simply implement the required methods of that delegate in your view controller class, and that should do it. If I'm missing something about how you're implementing this, then you need to provide more code examples to examine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文