IQKeyboardManager很好用。 IQKeyboardManager继承简单。 IQKeyboardManager持续更新。bash
最新很偶然的机会了解到IQKeyboardManager第三方库,感受从各方面比较,都比我如今使用的TPKeyboardAvoiding好。因此果断的替换。整个APP测试了一边,感受不错,彻底符合要求。直到5小时前,我开始编写一个UITableView的UITableViewCell中嵌套UITextView,进行调试时,出现了崩溃的现象。app
应该仍是个人代码的问题,开始筛选缘由吧。组件化
#解决 发现原来UIViewExtensions类中的方法测试
- (UIView*) superviewOfClassType: (Class) classType
{
UIView* view = self.superview;
while (view != nil)
{
if ([view isKindOfClass: classType])
{
return view;
}
view = view.superview;
}
return nil;
}
复制代码
与IQKeyboardManager库中IQUIView+Hierarchy类重名了,也就是所说的覆盖了。ui
-(UIView*)superviewOfClassType:(Class)classType
{
UIView *superview = self.superview;
while (superview)
{
if ([superview isKindOfClass:classType])
{
//If it's UIScrollView, then validating for special cases if ([superview isKindOfClass:[UIScrollView class]]) { NSString *classNameString = NSStringFromClass([superview class]); // If it's not UITableViewWrapperView class, this is internal class which is actually manage in UITableview. The speciality of this class is that it's superview is UITableView. // If it's not UITableViewCellScrollView class, this is internal class which is actually manage in UITableviewCell. The speciality of this class is that it's superview is UITableViewCell. //If it's not _UIQueuingScrollView class, actually we validate for _ prefix which usually used by Apple internal classes
if ([superview.superview isKindOfClass:[UITableView class]] == NO &&
[superview.superview isKindOfClass:[UITableViewCell class]] == NO &&
[classNameString hasPrefix:@"_"] == NO)
{
return superview;
}
}
else
{
return superview;
}
}
superview = superview.superview;
}
return nil;
}
复制代码
其实分类的方法重名并不存在覆盖的问题,只是在编译的时候谁的方法在前,那么谁的方法将会被执行。this
修改UIViewExtensions类中的方法后,显示正常。 spa
查看键盘弹出的UI界面能够清楚的看到,UITableViewWrapperView在键盘弹出后向上缩进,避免键盘所在的部分被覆盖。设计
仍是但愿IQKeyboardManager可以模仿AFNetworking或SDWebImage使用本身的前缀,避免这样的问题再次出现。3d
// END调试