将信息从 UIActionSheet 传递给委托
我对将数据传递回委托的理解完全围绕着创建一个新的视图控制器并使其符合协议。
我试图从使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不太明白为什么你要把你的委托任务放在 Main.m 中。我假设您正在 ViewController 中设置 UIActionSheet,并从那里启动它。在这种情况下,您的 ViewController 是您的委托对象。因此,您需要确保您的 ViewController 实现了 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:
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.