It seems simple, but I don’t know why its not working.
In my .h file I have declared: BOOL keyboardIsUp;
And then in my .m file:
-(void)keyboardWillShow {
NSLog(@"before:");
NSLog(keyboardIsUp? @"Yes" : @"No");
NSLog(@"keyboardWillShow");
keyboardIsUp = YES;
NSLog(@"after:");
NSLog(keyboardIsUp? @"Yes" : @"No");
...
}
-(void)keyboardWillHide {
NSLog(@"before:");
NSLog(keyboardIsUp? @"Yes" : @"No");
NSLog(@"keyboardWillHide");
keyboardIsUp = NO;
NSLog(@"after:");
NSLog(keyboardIsUp? @"Yes" : @"No");
...
}
-(BOOL)keyboardStatus{
NSLog(@"keyboardStatus");
NSLog(keyboardIsUp? @"Yes" : @"No");
return keyboardIsUp;
}
The methods are definitely being called correctly (I can see this from the NSLog messages) and with my NSLog messages within the first 2 methods, I can see that the BOOL is set correctly (within the scope of the function).
But when I call keyboardStatus, it always Logs “NO”
Any ideas? I’ve scoured the rest of my code I am definitely not changing the value of keyboardIsUp anywhere else.
Are you sure you are talking to the correct instance of your object?
I.e. add this to the beginning of each method:
If the hex number changes between
keyboardWillHide/ShowandkeyboardStatus, then you are talking to different instances. If not, something else is going on.