MonoTouch 和 MVC - 将 2 个视图挂钩到同一个控制器

发布于 2024-09-13 23:48:49 字数 337 浏览 2 评论 0原文

我需要编写一个适用于 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

北方的巷 2024-09-20 23:48:49

此链接讨论 .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.

り繁华旳梦境 2024-09-20 23:48:49

你不能只拥有一个基本控制器,然后在两个视图控制器中继承它吗?

Can you not just have a base controller and then inherit from that in both view controllers?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文