super respondsToSelector: returns true but actually calling super (selector) gives “unrecognized selector sent to instance”

后端 未结 5 1711
不知归路
不知归路 2021-01-01 12:40

OK, I am a little confused.

I have a subclass of UIScrollView, which is my attempt at a horizontally scrolling \"table view\" like UI element. UIScrollView itself s

5条回答
  •  误落风尘
    2021-01-01 13:19

    Unless you override responds to selector in your class you will be using the default implementation when you call super which will check the current instance. If you want to see if a instance of a type of object responds to a selector use +(BOOL)instancesRespondToSelector:(SEL)aSelector;

    This will check the object and its parent objects. So in your case you want to the following:

    [UIScrollView instancesRespondToSelector:@selector(gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:)]
    

提交回复
热议问题