English 中文(简体)
UIView需要推送UIViewController(委派)
原标题:UIView needs to push a UIViewController (delegation)

我很难理解海关代表团的情况——如果有人能帮助我,我将不胜感激:

我有一个带有选项卡栏控制器的UIViewController,其中每个都包含一个子类UIView。在其中一个视图中,我有一个UIButton,我想在其中加载一个UIDocumentInteractionController。我已经有了完成第二部分的代码,因为文档控制器需要访问UIViewController才能被推送到堆栈。

但是,我的UIView如何访问UIViewController?

我今晚在SO上读了很多东西,比如:

  • It can t be done
  • Set the UIViewController as a property of the UIView so it knows which it belongs to
  • Calling nextResponder on the UIViewController
  • Delegation

我可以很高兴地点击我的-(void)按钮Pressed:(id)sender方法,但它应该从哪里实现委派?假设这个方法存在于我的视图控制器中,它是否应该触发类似于[delegate documentRequested:sender]的东西?

提前感谢您的帮助。

最佳回答

我最近发布了一个关于如何使用自定义委派的详细答案。您可以在此处查看:解除ModalViewController并将数据传回

这里要做的是在UIView中实现协议,并将UIViewController设置为它的委托。

为了帮助您更好地理解链接的答案,在答案中,secondviewcontroller相当于您的UIView,firstviewcontroller等同于您的UI视图控制器。

问题回答

暂无回答




相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签