objectiveC协议问题详细信息 - >掌握沟通 [英] objectiveC protocol issue Detail -> Master communication

查看:119
本文介绍了objectiveC协议问题详细信息 - >掌握沟通的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用UISplitViewController来管理Master和Detail视图。从主人到细节,一切都很好。我可以从列表中选择一个项目,并通过委托更新详细信息视图。

I am using a UISplitViewController to manage the Master and Detail view. Everything is working fine going from master to detail. I can select an item from the list and through the delegate it updates the detail view.

我希望能够使用详细信息视图上的按钮删除项目。这在细节视图上非常简单。但是,我似乎无法弄清楚如何更改主视图以反映项目已被删除的事实。

I want to be able to delete an item using a button on the detail view. This is very simple to do on the detail view. However, I cannot seem to figure out how to change the master view to reflect the fact that an item has been deleted.

这是我的例子: SampleCode

推荐答案

使主人成为详细视图的代表。也就是说:当您从主服务器启动详细信息时,请告知详细信息主服务器的详细信息,最好使用委托构造。这样,详细信息可以在发生任何更改时通知主服务器。

Make the master a delegate of the detail view. That is: when you fire up the detail from the master, tell the detail who the master is, preferably by using a delegate construction.That way the detail can inform the master when any changes should occur.

或者您也可以将数据放入CoreData,并在CoreData表中发生更改时自动通知主数据库。检查 NSManagedObjectContextObjectsDidChangeNotification 以获取更多信息。

Or you can also put the data in CoreData, and have the master notified automatically when a changes occurs in the CoreData tables. Check NSManagedObjectContextObjectsDidChangeNotification for more info.

这篇关于objectiveC协议问题详细信息 - >掌握沟通的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆