我正在修复我的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];
}
}
答案 0 :(得分:1)
假设您正在谈论self.companyTextField
:
self.companyTextField.backgroundColor = [UIColor whiteColor];
如果你在谈论主要观点:
self.view.backgroundColor = [UIColor whiteColor];
答案 1 :(得分:1)
将容器视图的背景颜色设置为白色。 (主窗口视图)以及scrollview背景颜色为白色。
或者如果您背后有另一个视图,请将其设置为白色。
编辑:您的代码显示滚动视图,检查其颜色。