1

I have a custom alert that I made using UIWindow which is supposed to appear above the keyboard. In iOS8 and below, this worked fine, however in iOS9 the alert window goes beneath the keyboard. Is this a bug or the intended behavior? Are there any work arounds or changes that can be made to have the UIWindow go above the keyboard?

Ser Pounce
  • 14,196
  • 18
  • 84
  • 169
  • http://stackoverflow.com/questions/32391704/how-to-display-uiview-over-keyboard-in-ios/32391975#32391975 – Midhun MP Sep 22 '15 at 08:43
  • 3
    @MidhunMP It's not the same question, it's different. I'm asking about behavior for a UIWindow that has worked in previous versions of iOS. He's asking about a UIView. UIWindow, though a subclass of UIView, is presented a little bit differently. But the bottom line is that the same behavior should be working in iOS9 but isn't. – Ser Pounce Sep 22 '15 at 08:52
  • You can use the exact same code + makeKeyAndVisible method. Like this `UIWindow *win = [[UIWindow alloc] init]; win.backgroundColor = [UIColor redColor]; win.frame = CGRectMake(0, self.view.frame.size.height-200, 200, 200); [[[[UIApplication sharedApplication] windows] lastObject] addSubview:win]; [win makeKeyAndVisible];` – Midhun MP Sep 22 '15 at 09:03
  • @MidhunMP This does not work with UIWindow, it crashes the app. – Ser Pounce Sep 22 '15 at 09:20
  • The above code works perfectly in Xcode 7 and iOS 9. I tested it before posting it here. Can you put the crash log in comments ? – Midhun MP Sep 22 '15 at 09:24
  • @MidhunMP Or I should say it works when you're putting the alert over the keyboard, but my alert class can appear over the keyboard or on top of any window. That code only works when you try to put it on top of the keyboard, or else it crashes. So I'd have to detect if the keyboard was on screen. – Ser Pounce Sep 22 '15 at 09:28
  • Instead of that you can check the windows count. In normal case there will be 1 window, if there is keyboard available the count will be greater than 1 – Midhun MP Sep 22 '15 at 10:04
  • @MidhunMP Forgot to say thanks for your assistance. Going to post an answer below on what I got to work which was based on your help. – Ser Pounce Oct 06 '15 at 05:01

0 Answers0