如何使用EventKit(日历)集成并仍然支持iOS 3.x(MonoTouch)?
我想使用 EventKit 将日历集成到我的 iPhone 和 iPad 应用程序中。但是,当我包含此代码(例如使用 MonoTouch.EventKit)时,该应用程序将无法在我的 OS 3.x 设备(iPod touch 2G)上运行。
有没有办法在 MonoTouch 中构建应用程序,并且最小操作系统版本仍然为 3.0,同时支持 iOS 4 和 EventKit?如何在不中断对 3.0 设备的支持的情况下为 iOS 4 设备添加 EventKit 功能?
I would like to use EventKit to integrate the Calendar in my iPhone and iPad apps. However, when I include this code such as using MonoTouch.EventKit the app will not run on my OS 3.x device (iPod touch 2G).
Is there a way to build an app in MonoTouch and still have the min OS version as 3.0 yet support iOS 4 and the EventKit at the same time? How can I include EventKit functionality for iOS 4 devices without breaking support for 3.0 devices?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如 bosmacs 所提到的,要完成此任务,您需要让 MonoTouch 知道您需要“弱”链接到 EventKit 框架。弱绑定确保框架仅在第一次需要框架中的类时按需加载。
为此,您应该执行以下步骤:
导航至 iPhone 构建窗格。
iAd"' 到每个的额外参数
您想要弱链接的配置
除此之外
,您还需要防止您使用的类型在旧版本的 iOS 上运行,因为它们可能不存在。有多种方法可以完成此操作,但其中之一是解析 UIDevice.CurrentDevice.SystemVersion。
As mentioned by bosmacs, to accomplish this you need to let MonoTouch know that you need to link against the EventKit framework "weakly". Weak bindings ensure that the framework is only loaded on demand the first time a class from the framework is required.
To do this you should take the following steps:
navigate to the iPhone Build pane.
iAd"' to the Extra Arguments for each
configuration you wish to weakly link
on
In addition to this you will need to guard your usage of the types from running on older versions of iOS where they may not exist. There are several methods to accomplish this, but one of which is parsing UIDevice.CurrentDevice.SystemVersion.
您应该能够弱链接 EventKit 框架,然后在运行时检查您需要的类是否存在。另请参阅:通用应用程序 (OS3.2) 中的 EventKit、iPhone 检查 AVCaptureSession 类是否存在 和 您如何选择使用iPhone OS 3.0 功能在 2.0 兼容应用程序中?
通过将项目设置中的部署目标设置为 3.0,但针对 4.x SDK 进行编译,应该注意弱链接方面为你。
You should be able to weak-link the EventKit framework, then check at runtime for the existence of the classes you need. See also: EventKit in Universal app (OS3.2), iPhone checking for existence of AVCaptureSession Class and How do you optionally use iPhone OS 3.0 features in a 2.0 compatible app?
By setting your deployment target in your project settings to 3.0, but compiling against a 4.x SDK, the weak linking aspect should be taken care of for you.