0

I am trying to use

transitionFromView

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:)]

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?

Thanks.

esilver
  • 27,713
  • 23
  • 122
  • 168

2 Answers2

3

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:)];
Joe
  • 56,979
  • 9
  • 128
  • 135
  • You're right, I hadn't realized I could call @selector in that way. Thanks! – esilver Mar 29 '11 at 19:52
  • instead of `[[UIView class] respondsToSelector:@selector(transitionFromView:toView:duration:options:completion:)]` you can just write `[UIView respondsToSelector:@selector(transitionFromView:toView:duration:options:completion:)]` – user102008 Jun 12 '12 at 21:54
0

respondsToSelector: is an instance method, not a class method. You should be calling it on a specific instance of a UIView.

GendoIkari
  • 11,734
  • 6
  • 62
  • 104
  • 1
    No, that is not correct. You may call respondsToSelector: on a class method. http://stackoverflow.com/questions/1135366/class-method-equivalent-of-respondstoselector – esilver Mar 29 '11 at 19:51
  • Oops... that's interesting... how come the docs only list `-(BOOL)respondsToSelector:(SEL)aSelector`, and no `+(BOOL)respondsToSelector:(SEL)aSelector` method? – GendoIkari Mar 29 '11 at 19:54