IBAction/IBOutlet - 模型视图控制器
在MVC设计模式中,哪个类文件(appdelegate、viewcontroller等)最适合这些IBOutlet/IBAction场景?:
- 由UIButton按下事件触发的IBAction(例如显示菜单)?
- IBOutlet 来操作UI 元素属性(例如隐藏菜单)?
浏览 Apple 的示例代码似乎显示 IBOutlet 存在于 AppDelegate 和/或 ViewController 中,而 IBActions 仅存在于 ViewController 中。
关于哪种方式最符合“正确方式”/MVC 设计模式的任何输入?
谢谢!
In the MVC design pattern, which class file (appdelegate, viewcontroller etc) is best suited for these IBOutlet/IBAction scenarios?:
- IBAction (e.g. Show Menu) to be triggered by UIButton press event?
- IBOutlet to manipulate a UI elements properties (e.g. Hide Menu)?
A poke around Apple's sample code seems to show IBOutlets existing in the AppDelegate and/or the ViewController, and IBActions being in the ViewController only.
Any inputs on which way best aligns with the "right way"/MVC design patterns?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将需要附加到该笔尖的视图控制器文件中的这两个内容。因此,如果您有 MainMenuViewController.h/.m 和 MainManuViewController.xib,您将需要将操作和出口放在那里。
您实际上只想使用应用程序委托在启动时设置一些内容(例如根视图)或执行一些应用程序范围内的操作,例如在启动或退出时保存或加载数据。应用程序委托中的出口通常位于 MainWindow.xib 文件中,用于初始应用程序设置。
You're going to want both of those things in the View Controller file that is attached to that nib. So if you have a MainMenuViewController.h/.m and MainManuViewController.xib you'll want to put the actions and outlets in there.
The App Delegate you really only want to use to set up some things on launch (like your root views) or do some app-wide actions, like saving or loading data on launch or quit. The outlets in the App Delegate are usually in the MainWindow.xib file, and are for initial app setup.