如何告诉 UIViewController UIPopOverController 中的按钮被按下?
我认为标题是不言自明的。 我有一个 UIPopOverController,其中是一个表格视图,当我选择一个单元格时,我想告诉它 UIViewController。
有一个简单的解决方案还是我需要 KeyValueObserving 或通知?
i think the title is self explaining.
I have an UIPopOverController, in it is a tableview and when i select a cell, i want to tell it the UIViewController.
Is there an easy solution or do i need KeyValueObserving or notifications?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从 tableview 发布 NSNotification 并将 UIViewController 添加为观察者。
Post an NSNotification from the tableview and add the UIViewController as an observer.
您可以根据您的选择采用两种方法之一进行移动。
首先:使用委托/协议。
http://www.thepectiveprogrammer.com/2010/05 /objective-c-protocols-and-delegates.html
第二: 将 UIViewController 设置为 UIButton 的目标。
例如
you could move with one of two approaches as per your choice.
first : using delegate/protocol.
http://www.thepensiveprogrammer.com/2010/05/objective-c-protocols-and-delegates.html
second: Set your UIViewController as the target for your UIButton.
for example
发布 NSNotification 效果很好...您还可以在 UITableViewController 类中创建回调对象和选择器。
您可以使用回调对象和回调选择器初始化 UITableViewController
...将值保存到属性,
然后从 tableView 中的 didSelectRowAtIndexPath ...调用
使用此方法,您可以根据需要定义自己的回调方法...从您的创建弹出窗口的 ViewController 类,你可以做这样的事情......
Posting an NSNotification will work well... you can also create a callback object and selector in your UITableViewController class.
you could initialize your UITableViewController with a callback object and callback selector
...save off the values to properties
then from the didSelectRowAtIndexPath in your tableView... call
using this methodology, you can define your own callback methods as you wish.. from your ViewController class that created the popover, you could do something like this...