推荐的方式在运行时测试IOS版本特定功能 [英] Recommended way to test for iOS Version specific feature at runtime

查看:235
本文介绍了推荐的方式在运行时测试IOS版本特定功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打靶的iOS 4.3和5.0,内置对5.0 SDK的应用程序,并且希望增加对iOS5的中引入了微博功能的支持,只有当一个应用程序的iOS5设备上运行。什么是无需您的应用程序崩溃的推荐方式为在运行这些操作系统功能的可用性可靠地测试?

I'm targetting IOS 4.3 and 5.0 with an app built against the 5.0 SDK and would like to add support for the Twitter functionality introduced in iOS5 only when the app runs on a iOS5 device. What is the recommended way to reliably test for the availability of these OS features at runtime without having your app crash?

我知道你在Objective-C做到这一点使用respondsToSelector但?它是如何在C#中做

I know you do this using respondsToSelector in Objective-C but how is it done in C#?

推荐答案

通过,您可以使用下面的代码最近MonoTouch的版本:

With recent MonoTouch versions you can use the following code:

        if (UIDevice.CurrentDevice.CheckSystemVersion (5, 0)) {
            window.RootViewController = navigation;
        } else {
            window.AddSubview (navigation.View);
        }



否则你可以得到一个字符串 UIDevice.CurrentDevice.SystemVersion 并做一些检查,用自己的代码。

Otherwise you can get a string from UIDevice.CurrentDevice.SystemVersion and do some checks with your own code.

这篇关于推荐的方式在运行时测试IOS版本特定功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆