gpt4 book ai didi

objective-c - 将文件菜单项链接到按钮

转载 作者:行者123 更新时间:2023-12-03 16:39:05 24 4
gpt4 key购买 nike

我需要将“基于文档”应用程序中的一些按钮链接到文件菜单(粗体文本、斜体文本、放大文本等)。问题是,由于它是一个基于文档的应用程序,MainMenu.xib 是一个与 MyDocument.xib 完全不同的 XIB 文件,因此我无法像通常那样在 Interface Builder 中拖动连接。有人有解决方法吗?有没有办法将按钮操作链接到单独的 XIB 文件的内置菜单功能?

扎克

最佳答案

通常,您使用First Responder占位符对象。

About the First Responder

"In Interface Builder, the First Responder is a proxy object that represents the first object in your application’s dynamically determined responder chain. Because the responder chain of an application cannot be determined at design time, the First Responder proxy acts as a stand-in target for any action messages that need to be directed at the application’s responder chain. Menu items commonly target the First Responder proxy. For example, the Minimize menu item in the Window menu hides the frontmost window in an application, not just a specific window, and the Copy menu item should copy the current selection, not just the selection of a single control or view. Other objects in your application can target the First Responder as well."

另请参阅: Connecting Menu Items Across Nib Files

此外,如果您想创建其操作与“格式”>“粗体”等命令基本相同的按钮,请参阅:Connecting the Font Menu in Interface Builder 3

关于objective-c - 将文件菜单项链接到按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4731670/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com