質問

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