简体   繁体   中英

How to avoid that a deprecated method is called in Xamarin iOS?

willRotateToInterfaceOrientation:duration is deprecated since iOS 8. So the WillRotate is also deprecated in Xamarin iOS. But WillRotate will still be called on iOS 8.

How can I assure that this method is not called by an iOS 8 device? Do I need something like a compiler directive? RespondsToSelector will not work here.

由于不建议使用,并且您使用最新的SDK目标编译了应用,因此不会调用它。

This functionality depends on the method being implemented or not. While many APIs were deprecated, the functionality is still present for backwards compatibility.

What this means in this particular case is that if you implement the method (or any of the other supporting methods in the family), the method will be invoked. If you do not implement it, the new methods will be called.

Which ones depend on what exactly the underlying framework is using to probe for. They are likely using RespondsToSelector() and based on presence/absence of a method execute one code path or another.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM