本文将分享怎么实现:利用响应链机制寻找UIView及其子类所在的控制器。(响应链) 这里不做解释,读者可以自己查阅资料。

原因及其解决方案
原因: 在项目中,可能由于项目复杂度很高,导致某些单个页面的UIView及其子类嵌套层级太深,从而会引发事件回调过于繁琐。
解决方案 : 为了避免这种复杂度,本人就利用响应链机制解决该问题,使得UIView及其子类得以自我救赎。
Talk is cheap, show me the code! (哈哈。。。)
给UIView做了分类: UIView+viewController
UIView+viewController.h

UIView+viewController.m

网友评论