Keyboard hides TabBar
Asked Answered
F

3

9

I am working in a TabBar app. In one view there is a UISearchBar and, when is pressed, the keyboard appears.

The problem is that the keyboard hides the tabbar.

Do you know how to solve it?

Fecteau answered 11/3, 2011 at 11:22 Comment(3)
When the user is concentrating on typing something to search in the search bar, why do you want the tabs to be shown ?Tarbox
I also would say that is standard behaviour and you should not change that.Slavin
@Tarbox my reviews wants that, is not my fault :PFecteau
A
-1

To my knowledge you cant move keyboard .. so try to use transformation to move the tab-bar above keyboard

Taken from here

Another link

Alfonzoalford answered 11/3, 2011 at 11:26 Comment(0)
I
15

It's been a while since this was asked, but for the sake of documentation, here it goes: First, subscribe to the NSNotificationCenter to receive the keyboard notification:

-(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];
}

don't forget to unsubscribe

- (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];
}

Then implement the function that will be called by the notification center:

- (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];
 }];

This will animate the TabBar at the keyboard's pace and keep it on top.

Ironclad answered 8/2, 2013 at 22:38 Comment(2)
I would recoment using UIKeyboardDidChangeFrameNotification otherwise you will run into trouble with split keyboards https://mcmap.net/q/764915/-check-for-split-keyboard.Cunning
self.tabBarController?.view.frame.origin.y = 0.0 . just to go back to normal when the keyboard hides.Bozen
A
-1

To my knowledge you cant move keyboard .. so try to use transformation to move the tab-bar above keyboard

Taken from here

Another link

Alfonzoalford answered 11/3, 2011 at 11:26 Comment(0)
W
-1

I solved this by showing a custom keyboard instead of the native uikeyboard.

Download the sample project from this github link.

customize the keypad to the desired native keypad either it is number or words.

Then place the uibuttons below the custom keypad with tabbar controllers like image like below image. Try this(future visitors), it may solve the issue.

enter image description here

Warrant answered 18/6, 2013 at 13:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.