在 UIView 上测试类方法以保持向后兼容性 [英] Testing for a class method on UIView to maintain backward compatibility

查看:26
本文介绍了在 UIView 上测试类方法以保持向后兼容性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用

transitionFromView

从 iOS 4 开始,这是 UIView 上的一个类方法.以下所有方法在 4.2 模拟器中都返回 false:

Which is a class method on UIView as of iOS 4. All of the following methods return false in the 4.2 simulator:

[UIView respondsToSelector:@selector(transitionFromView:)]
[UIView respondsToSelector:@selector(transitionFromView)]
[[UIView class] respondsToSelector:@selector(transitionFromView)]
[[UIView class] respondsToSelector:@selector(transitionFromView:)]

Stack 上的其他文章建议前两种方法之一应该返回 true.测试此方法的适当方法是什么,使其在运行 iOS 3 时不会崩溃?

Other articles on Stack suggest that one of the first two methods should have returned true. What is the appropriate way to test for this method so it will not crash when runing iOS 3?

谢谢.

推荐答案

您缺少 UIView.您要使用以下内容

You are missing part of the selector for the UIView. You want to use the following

BOOL responds = [[UIView class] respondsToSelector:@selector(transitionFromView:toView:duration:options:completion:)];

这篇关于在 UIView 上测试类方法以保持向后兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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