MonoTouch 和 MVC - 将 2 个视图挂钩到同一个控制器
我需要编写一个适用于 iPhone 和 iPad 的应用程序。
我遇到的问题是如何设置 iPadView 和 iPhoneView 来连接到同一个控制器?
换句话说,我不想有任何重复的控制器代码——我只需要为每个设备创建不同的视图。
现在,我通过选择“添加->新文件->带有控制器的iPhone视图”来链接视图->控制器,这适用于一台设备。但是我连接的事件处理程序中的代码不必通过“添加->新文件->带有控制器的iPad视图”来重复。
教程的链接可能会有所帮助,我已经进行 .Net Windows 开发一段时间了,但仍在学习 iPhone 和 MonoTouch。
I need to write an app that runs for iPhone and iPad.
The issue I'm running into is how do you setup an iPadView and an iPhoneView to hook to the same controller?
In other words, I don't want to have any duplicate controller code--I should only have to make a different view for each device.
Right now I link up view->controller by choosing "Add->New File->iPhone View with Controller", and this works for one device. But the code in the event handlers I have wired up should not have to be duplicated by going to "Add->New File->iPad View with Controller".
A link to a tutorial may help, I have been doing .Net Windows development for a while but still learning iPhone and MonoTouch.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此链接讨论 .xib 文件的代码生成:
MonoTouch Doc
显然,您可以删除 .xib。 Designer.cs 文件以关闭代码生成。这是正确的做法吗?
否则我会将其标记为答案。
This link talks about code generation for .xib files:
MonoTouch Doc
Apparently you can just delete your .xib.designer.cs file to turn off the code generation. Is this the right way to do it?
Otherwise I'll mark this as the answer.
你不能只拥有一个基本控制器,然后在两个视图控制器中继承它吗?
Can you not just have a base controller and then inherit from that in both view controllers?