Question

I am creating a custom alert view similar to a UIAlertView. What I'm running into is that when a UITextField becomes active in the background while my alert is visible, the keyboard slides up over it.

If I add the alert view to the main window like so:

[[[UIApplication sharedApplication] keyWindow] addSubview:myAlert];

It will appear over an existing keyboard but will still be obscured if a keyboard becomes active after the alert is presented.

This sort of scenario often occurs when navigating from one view to another. The exiting view triggers an alert on exit and the next view wants to activate a UITextField or something.

Was it helpful?

Solution

Maybe you can add your custom alert view to a new window and set this window's windowLevel to UIWindowLevelAlert or higher.

OTHER TIPS

I found a really good approach and explanation here.

Did you try overriding the method

- (BOOL)canResignFirstResponder

and returning NO ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top