So after my long search via google and SO, I have not found a similar issue. Some came close but not like mine.
Issue at hand: In my app (WKWebView based) if the keyboard is shown, and I double tap home and switch to another app which the keyboard is shown, my apps keyboard is hidden. Not an issue. So when I multitask again, in the snapshot it takes of my app, the keyboard is gone, but the custom toolbar I have above it seemed to remain in place with no keyboard below. I tap my app and it animates up and then back down to the bottom of the screen.
What I've tried: I know about the [self.view endEditing:YES], resigningFirstResponder and all the methods to close the keyboard. Tried placing and mixing through the viewWillDisappear, applicationWillResignActive and applicationDidEnterBackground. None of which will handle my toolbar issue.
This is how I'm animating my keyboard on and off the screen, while keeping the toolbar visible.
- (void)keyboardWillShow:(NSNotification*)notification
{
NSDictionary* info = [notification userInfo];
NSNumber *durationValue = info[UIKeyboardAnimationDurationUserInfoKey];
NSNumber *curveValue = info[UIKeyboardAnimationCurveUserInfoKey];
NSValue *endFrame = info[UIKeyboardFrameEndUserInfoKey];
[UIView animateWithDuration:durationValue.doubleValue
delay:0
options:(curveValue.intValue << 16)
animations:^{
self.toolBar.frame = CGRectMake(0,
[endFrame CGRectValue].origin.y - self.toolBar.bounds.size.height+44,
self.toolBar.bounds.size.width,
self.toolBar.bounds.size.height);
}
completion:nil];
}
- (void)keyboardWillHide:(NSNotification*)notification
{
NSDictionary* info = [notification userInfo];
NSNumber *durationValue = info[UIKeyboardAnimationDurationUserInfoKey];
NSNumber *curveValue = info[UIKeyboardAnimationCurveUserInfoKey];
NSValue *endFrame = info[UIKeyboardFrameEndUserInfoKey];
[UIView animateWithDuration:durationValue.doubleValue
delay:0
options:(curveValue.intValue << 16)
animations:^{
self.toolBar.frame = CGRectMake(0,
[endFrame CGRectValue].origin.y - self.toolBar.bounds.size.height,
self.toolBar.bounds.size.width,
self.toolBar.bounds.size.height);
}
completion:nil];
}
Does anybody have a clue or thought?
Again my app is WKWebView based, so directly calling or directing towards textviews, trying to focus in the webview is pointless.
If anybody needs some more code, just let me know. Any help would be appreciated. Thank You.
UPDATED 1/20/18
So here is the requested code pertaining to where and how my toolbar gets initialized and loaded.
h.
UIToolbar *toolBar;
@property (nonatomic, strong) UIToolbar *toolBar;
m.
@synthesize toolBar;
- (void)viewDidLoad {
//Toolbar setup
CGRect toolFrame, remain;
CGRectDivide(self.view.bounds, &toolFrame, &remain, 48, CGRectMaxYEdge);
self.toolBar = [[UIToolbar alloc] initWithFrame:toolFrame];
[self.toolBar setBarStyle:UIBarStyleBlackTranslucent];
[self.toolBar setClipsToBounds:YES];
[self.toolBar setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin];
[self.view addSubview:self.toolBar];
}
That's about it, other then some code calling to refresh it when I switch buttons, nothing else is tied to this toolbar.
This doesn't get called unless I tap a switch or need to refresh it when the user changes the background, Dealt with NSUserDefaults in another view.
-(void)viewWillLayoutSubviews{
[self.currentScrollView layoutIfNeeded];
[self.toolBar layoutIfNeeded];
[self.view layoutSubviews];
}