문제

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