Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Adding an OLGhostAlertView while displaying a keyboard will cause it to be placed under the keyboard #3

radutzan opened this Issue Aug 22, 2012 · 7 comments


None yet
4 participants

radutzan commented Aug 22, 2012

Since we can only receive notifications for keyboards if they are fired after we init an OLGhostAlertView, we can't know if there's one being displayed before instantiating the view, and therefore we cannot adjust the frame accordingly, causing the view to be placed under the keyboard in the view hierarchy.

There's really no way that we know of to fix this. Adding the view as a subview of the key window (#1) does allow for the view to be drawn on top of the keyboard, but this is not acceptable behaviour.

Well, this could be amended by using some keyboard listener that always receives these notifications from the beginning of the app's life cycle. Being a singleton (dispatch_once) you could query it for the status and keyboard height.

There are some examples of this, and I can give you one if needed.


radutzan commented Oct 5, 2012

This sounds great, it'd be awesome if you could give me some examples. Doing this would also fix #2.

Something like in my gist here: https://gist.github.com/3845949

You'd call it once in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
using [LWSKeyboardListener defaultListener]; to register for the notifications.

And in any other class you might want to know about the current state of the keyboard, just inlcude LWSKeyboardListener.h and get the properties of the shared instance (keyboardShowed, keyboardRect, keyboardHeight).

For example in OLGhostAlertview.m in the - (void)show method, add bottomMargin += [LWSKeyboardListener defaultListener].keyboardHeight; to account for the keyboard height.

I added keyboardHeight, because the keyboardRect doesn't care for the interface orientation and always has coordinates as if the device were upright, home button on the bottom. Therefore I simply return the minimum of width and height of the rect.


radutzan commented Oct 10, 2012

This looks like a nice solution, but I wanna keep OLGAV as simple as possible. I'll mention your comment on the README for people who need this fixed. Thanks a lot!

Yes, I understand completely. It's quite unfortunate that there is no public API for this.

@crowl crowl closed this Nov 26, 2012

@crowl crowl reopened this Nov 26, 2012


radutzan commented Feb 11, 2013

This can also be worked around using the position property.

pmkowal commented Aug 21, 2014

You can check my solution with the alert placement here #24.
In this solution the OLGhostAlertView:

  • doesn't need to be shown in or after viewDidAppear,
  • is always visible above the keyboard.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment