Iphone 键盘隐藏选项卡栏

Iphone 键盘隐藏选项卡栏,iphone,uitabbar,tabbar,iphone-softkeyboard,Iphone,Uitabbar,Tabbar,Iphone Softkeyboard,我在一个TabBar应用程序中工作。在一个视图中,有一个UISearchBar,当按下时,键盘出现 问题是键盘隐藏了选项卡栏 你知道怎么解决吗?据我所知,你不能移动键盘。。因此,尝试使用转换将选项卡栏移动到键盘上方 取自 另一个有一段时间没有提出这一问题,但为了便于记录,这里是: 首先,订阅NSNotificationCenter以接收键盘通知: -(void) viewWillAppear:(BOOL)animated { [[NSNotificationCenter defaultCent

我在一个TabBar应用程序中工作。在一个视图中,有一个UISearchBar,当按下时,键盘出现

问题是键盘隐藏了选项卡栏


你知道怎么解决吗?

据我所知,你不能移动键盘。。因此,尝试使用转换将选项卡栏移动到键盘上方

取自


另一个

有一段时间没有提出这一问题,但为了便于记录,这里是: 首先,订阅NSNotificationCenter以接收键盘通知:

-(void) viewWillAppear:(BOOL)animated
{
 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillToggle:)
                                             name:UIKeyboardWillShowNotification object:nil];
 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillToggle:)
                                             name:UIKeyboardWillHideNotification object:nil];
}
别忘了退订

- (void)viewWillDisappear:(BOOL)animated 
{
 [self.view endEditing:YES];
 [super viewWillDisappear:animated];
 [[NSNotificationCenter defaultCenter] removeObserver:self
                                                name:UIKeyboardWillShowNotification object:nil];
 [[NSNotificationCenter defaultCenter] removeObserver:self
                                                name:UIKeyboardWillHideNotification  object:nil];
}
然后实现通知中心将调用的功能:

- (void) keyboardWillToggle:(NSNotification *)aNotification
{
 CGRect frame = [[[self tabBarController] tabBar] frame];
 CGRect keyboard = [[aNotification.userInfo valueForKey:@"UIKeyboardFrameEndUserInfoKey"] CGRectValue];
 frame.origin.y = keyboard.origin.y - frame.size.height;
 [UIView animateWithDuration:[[aNotification.userInfo valueForKey:@"UIKeyboardAnimationDurationUserInfoKey"] floatValue] animations:^
 {
     [[[self tabBarController] tabBar] setFrame:frame];
 }];

这将以键盘的速度设置选项卡栏的动画,并使其保持在顶部。

我通过显示自定义键盘而不是本机的
ui键盘来解决这个问题

从该链接下载示例项目

将键盘自定义为所需的本机键盘(数字或文字)

然后将uibuttons放置在自定义键盘下方,并使用tabbar控制器,如下图所示。试试这个(未来的访问者),它可能会解决问题


当用户集中精力在搜索栏中键入要搜索的内容时,为什么要显示选项卡?我还想说这是标准行为,您不应该改变它。@Viraj我的评论想要这样,这不是我的错:PI建议使用
UIKeyboardDidChangeFrameNotification
,否则您将在拆分keyboards.self.tabBarController?.view.frame.origin.y=0.0时遇到问题。只是为了在键盘隐藏时恢复正常。