在iOS5消息应用程序中,您可以在键盘上向下滑动手指以使其上下移动。这也可以在AppStore中的iA Writer应用程序中完成。如何在代码中执行此操作,即访问和修改UIKeyboard的Y位置?
答案 0 :(得分:9)
为什么重新发明轮子?有几个开源项目可以模仿messages.app后退键盘:
答案 1 :(得分:2)
没有方法可以做到这一点,但您可以直接修改键盘的框架:
UIWindow* tempWindow;
//Because we cant get access to the UIKeyboard throught the SDK we will just use UIView.
//UIKeyboard is a subclass of UIView anyways
UIView* keyboard;
//Check each window in our application
for(int c = 0; c < [[[UIApplication sharedApplication] windows] count]; c ++)
{
//Get a reference of the current window
tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:c];
//Get a reference of the current view
for(int i = 0; i < [tempWindow.subviews count]; i++)
{
keyboard = [tempWindow.subviews objectAtIndex:i];
if([[keyboard description] hasPrefix:@"(lessThen)UIKeyboard"] == YES)
{
//If we get to this point, then our UIView "keyboard" is referencing our keyboard.
}
}
}