我正在修正UITextView,使其不在键盘下方显示,而是将其调整为正确的约束。这可能是一个愚蠢的问题,并且很可能在这个愚蠢的问题旁边有一个简单的解决方法,但是我需要将视图(当前为黑色)的颜色涂成whiteColor
-看来我在正确的行上空白了这样做的代码。我已经搜索了Stack Overflow和Google一段时间,但没有找到一行不会返回错误的代码。
键盘后面的黑色矩形。
- (void)keyboardDidShow:(NSNotification *)aNotification {
NSDictionary* info = [aNotification userInfo];
CGRect kbRect = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
kbRect = [[self view] convertRect:kbRect fromView:nil];
CGSize kbSize = kbRect.size;
CGRect aRect = self.view.frame;
/* This should work, but doesn't quite qet the job done */
// UIEdgeInsets insets = self.textView.contentInset;
// insets.bottom = kbSize.height;
// self.textView.contentInset = insets;
//
// insets = self.textView.scrollIndicatorInsets;
// insets.bottom = kbSize.height;
// self.textView.scrollIndicatorInsets = insets;
/* Instead, we just adjust the frame of the uitextview */
aRect.size.height -= kbSize.height + VERTICAL_KEYRBOARD_MARGIN;
self.companyTextField.frame = aRect;
// If active text field is hidden by keyboard, scroll it so it's visible
// Your application might not need or want this behavior.
if (!CGRectContainsPoint(aRect, self.companyTextField.frame.origin) ) {
CGPoint scrollPoint = CGPointMake(0.0, self.companyTextField.frame.origin.y - kbSize.height);
[self.companyTextField setContentOffset:scrollPoint animated:YES];
}
}
假定您正在谈论self.companyTextField
:
self.companyTextField.backgroundColor = [UIColor whiteColor];
如果您正在谈论主视图:
self.view.backgroundColor = [UIColor whiteColor];
将容器视图的背景色设置为白色。 (主窗口视图),以及scrollview背景颜色为白色。
或者如果后面有其他视图,则将其设置为白色。
编辑:您的代码显示滚动视图,检查其颜色。