c# - How to check if a certain method/class/API exists in Xamarin iOS? -


After the

it is recommended to check for a specific API like this

  IsiOS7 bool public stable {Returns UIDevice.CurrentDevice.CheckSystemVersion (7, 0); }} If (Util.IsiOS7) {// call iOS 7 API} and {// iOS 6.1 or earlier API call}   

The same should go for iOS 8. Now I have read that you should check whether there is a certain method or class exists rather than checking the version. Here comes the RespondsToSelector that should be something like this

  if (RespondsToSelector (new selector ("edgesForExtendedLayout"))) EdgesForExtendedLayout = UIRectEdge.None.   

But how will one examine if a whole class exists like UIAlertController ? In Objective-C, there is no NSClassFromString I have seen in some such purpose -

  if ([UIAlertController class]) {// ...} < / Code>  

Will such a move happen?

  type type = type Gettype ("UIAlertController"); If (type! = Null) {// iOS 8 API} other {// iOS 7 or lower}   

How will this happen in C #? Or to check for UIAlertController for other methods, UISearchController , ... and so on.

do this: < Using code> MonoTouch.ObjCRuntime; Bool hasUIAlertController = Class.GetHandle ("UIAlertController")! = IntPtr.Zero; If (HuiLeart Controller) {// iOS 8} and {// iOS 7 or lower}

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -