开发者

How to use EventKit (Calendar) integration and still support iOS 3.x (MonoTouch)?

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 ca开发者_JAVA百科n I include EventKit functionality for iOS 4 devices without breaking support for 3.0 devices?

Thanks


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:

  • Open your Project Options and navigate to the iPhone Build pane.
  • Add '-gcc_flags "-weak_framework
    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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜