在iOS 8中,下面的行编译得很好,但是返回错误。为什么?
[[NSLayoutConstraint class] respondsToSelector:@selector(setActive:)]但是,以下内容正确地返回了true -
[self.heightLayoutConstraint respondsToSelector:@selector(setActive:)]其中self.heightLayoutConstraint的类型为NSLayoutConstraint。
发布于 2015-04-08 21:06:24
setActive:不是NSLayoutConstraint上的类方法,因此返回值是正确的:类本身不响应该选择器。
我想你是在找类方法+instancesRespondToSelector:
[NSLayoutConstraint instancesRespondToSelector:@selector(setActive:)]https://stackoverflow.com/questions/29525248
复制相似问题