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調試