![在此处输入图像说明] [1] 当我尝试添加窗口作为其中包含视图的子视图时,键盘在屏幕底部稍微离开。怎么解决?这是我的代码。
keyboardWindowFrame = nil;
keyboardWindowFrame = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
for(UIView* potentialKeyboard in keyboardWindowFrame.subviews)
{ // if the real keyboard-view is found, remember it.
if([[potentialKeyboard description] hasPrefix:@"<UIPeripheralHost"] == YES)
{
NSLog(@"Keyboard Frame: %@",NSStringFromCGRect(potentialKeyboard.frame));
keyboard = potentialKeyboard;
[keyboard addSubview:viewForGlobeEmoji];
[self.view addSubview:keyboard];
}
}
以下是附加屏幕截图:
现在添加
后工具栏和键盘之间有空格 if([[potentialKeyboard description] hasPrefix:@"<UIPeripheralHost"] == YES)
{
NSLog(@"potentialKeyboard: %@",NSStringFromCGRect(potentialKeyboard.frame));
keyboard = potentialKeyboard;
CGRect frame = keyboard.frame;
frame.origin.y = 332;
keyboard.frame = frame;
[keyboard addSubview:viewForGlobeEmoji];
[self.view addSubview:keyboard];
}
答案 0 :(得分:0)
你应该在这一行下方设置键盘框架:
keyboard = potentialKeyboard;
CGRect frame = keyboard.frame;
frame.origin.y = xxx;
keyboard.frame = frame
答案 1 :(得分:0)
做这样的事情是完全错误的,并且不会受到appstore评论员的欢迎。您正在篡改未记录的系统API,这只是意外行为的结果。
如何做到你想要的标准方法: