iOS_Tips
iOS_Tips copied to clipboard
SLEditTextView的两个bug
-
切换键盘样式,会自动多生成一个此视图
-
使用搜狗键盘自动缩回键盘时,此视图无法恢复到原状
修改代码:
- //颜色选择菜单视图
-
(void)colorSelectionView:(CGFloat)keyboardHeight { // for (UIView *subView in self.subviews) { // if (subView != self.doneEditBtn || subView != self.cancleEditBtn || subView != self.textView) { // continue; // }else { // [subView removeFromSuperview]; // } // }
for (UIView *view in self.subviews) { if ([view isEqual:self.cancleEditBtn] || [view isEqual:self.doneEditBtn] || [view isEqual:self.textView]) { continue; } [view removeFromSuperview]; }
-
添加键盘消失监听事件
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
//键盘即将消失
- (void)keyboardWillHide:(NSNotification *)notification{ [self.textView resignFirstResponder]; if (self.editTextCompleted) { self.editTextCompleted(nil); } [self removeFromSuperview]; }
@yaoyongmin 好的,感谢