如何将视图 B 中的文本字段内容发送到视图 A?
我在 UIView A
中创建了一个 tableview A
,其中包含来自 Am 文件中定义的 plist 文件的 tabledatasource
。 tableview
中的条目是带有 keyA
、keyB
、keyC
等的字典。
现在我要走了在UIView
A中创建一个UIButton
,并创建一个新的modalview B。按下按钮时,会弹出modalview B。在模态视图 B 中,会有一些 UITextfields 供用户填写。用户在文本字段中填写的信息将写入plist文件(如上所述),然后重新加载表格视图A的内容。
我的问题是,用户在模态视图B中填写信息。但是表格视图A位于< code>UIView A. 好像我当前在modalview B上使用App时无法更改tableview A的内容?
是否有办法可以将视图 B 中输入的信息传递到视图 A? 多谢。
I created a tableview A
in UIView A
, with a tabledatasource
from a plist file defined in the A.m file. The entries in the tableview
are dictionaries with keyA
, keyB
, keyC
, and etc.
Now I'm going to create a UIButton
in UIView
A and a new modalview B. When the button is pressed , modalview B will pop up. In modalview B, there will be a few UITextfields
to be filled in by the users. The information that user fill in the textfields will write to the plist file(as mentioned above), and then reload the content of the tableview A.
My question is, users fill in informations in modalview B. But the tableview A is in the UIView
A. It seems that I can not change the content of tableview A when I am currently using the App on the modalview B?
If there's a way that I can pass the informations entered in view B to view A?
Thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用自定义协议 - 这称为委托模式
//ClassA.h
ClassB.h
将委托设置为 ClassA -
按钮操作中的接收器(在 b 类中)
只是说
Use custom Protocals - This is called delegate pattern
//ClassA.h
ClassB.h
Set delegate to ClassA - receiver
In button action (in Class b)
just say
您通常使用委托模式来实现此行为。查看 Apple 文档中的 iPhoneCoreDataRecipes 示例。特别是查看类
You typically achieve this behavior using the delegate pattern. Check out the example iPhoneCoreDataRecipes in the Apple documentation. In particular look at the classes
我想我误解了你的问题。好的,就像 sanjeev 说的那样,你可以使用代表。或者你可以使用 NSNotification。在视图 A 和要修改 plist 的视图 B 中添加通知观察者发布通知。
查看此示例
I think i misunderstood your question. ok so like sanjeev said you can use delegates. Or you can use NSNotification. Add a notification Observer in View A and in view B where you are modifying plist Post a notification.
See This Example