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.

有帮助吗?

解决方案

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

其他提示

I found a really good approach and explanation here.

Did you try overriding the method

- (BOOL)canResignFirstResponder

and returning NO ?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top