Reputation: 8754
I have a UISearchBar in a view which I am presenting using:
view.addSubview(searchView)
searchView.mySearchBar.becomeFirstResponder()
This works fine in most cases if I am simply typing the text into the search bar without touching it. However if I tap the searchbar (lets say to place the cursor at another spot or to copy/paste text etc), then Xcode prints the following warning:
[Assert] UITextEffectsWindow should not become key. Please file a bug to Keyboard | iOS with this call stack: (
0 UIKitCore 0x0000000190cd3e14 00EA1426-38F7-3FD2-BE01-04EBD44ECA35 + 14769684
1 UIKitCore 0x0000000190a2e028 00EA1426-38F7-3FD2-BE01-04EBD44ECA35 + 11993128
2 UIKitCore 0x0000000190c98ca8 00EA1426-38F7-3FD2-BE01-04EBD44ECA35 + 14527656
3 UIKitCore 0x0000000190c77510 00EA1426-38F7-3FD2-BE01-04EBD44ECA35 + 14390544
4 UIKitCore 0x0000000190c780c4 00EA1426-38F7-3FD2-BE01-04EBD44ECA35 + 14393540
5 UIKitCore 0x00000001909e5d54 00EA1426-38F7-3FD2-BE01-04EBD44ECA35 + 11697492
6 UIKitCore 0x00000001904d0f1c 00EA1426-38F7-3FD2-BE01-04EBD44ECA35 + 6369052
7 UIKitCore 0x0000000190568a4c 00EA1426-38F7-3FD2-BE01-04EBD44ECA35 + 6990412
8 UIKitCore 0x0000000190571fc0 00EA1426-38F7-3FD2-BE01-04EBD44ECA35 + 7028672
9 UIKitCore 0x000000019056ec48 00EA1426-38F7-3FD2-BE01-04EBD44ECA35 + 7015496
10 UIKitCore 0x000000019056e210 00EA1426-38F7-3FD2-BE01-04EBD44ECA35 + 7012880
11 UIKitCore 0x00000001905627a0 00EA1426-38F7-3FD2-BE01-04EBD44ECA35 + 6965152
12 UIKitCore 0x0000000190561b30 00EA1426-38F7-3FD2-BE01-04EBD44ECA35 + 6961968
13 UIKitCore 0x0000000190a22534 00EA1426-38F7-3FD2-BE01-04EBD44ECA35 + 11945268
14 UIKitCore 0x00000001909fd934 00EA1426-38F7-3FD2-BE01-04EBD44ECA35 + 11794740
15 UIKitCore 0x0000000190a7fa20 00EA1426-38F7-3FD2-BE01-04EBD44ECA35 + 12327456
16 UIKitCore 0x0000000190a841c0 00EA1426-38F7-3FD2-BE01-04EBD44ECA35 + 12345792
17 UIKitCore 0x0000000190a7b480 00EA1426-38F7-3FD2-BE01-04EBD44ECA35 + 12309632
18 CoreFoundation 0x000000018e120240 F80FCA31-BF76-3293-8BC6-1729588AE8B6 + 631360
19 CoreFoundation 0x000000018e120140 F80FCA31-BF76-3293-8BC6-1729588AE8B6 + 631104
20 CoreFoundation 0x000000018e11f488 F80FCA31-BF76-3293-8BC6-1729588AE8B6 + 627848
21 CoreFoundation 0x000000018e119a40 F80FCA31-BF76-3293-8BC6-1729588AE8B6 + 604736
22 CoreFoundation 0x000000018e119200 CFRunLoopRunSpecific + 572
23 GraphicsServices 0x00000001a4214598 GSEventRunModal + 160
24 UIKitCore 0x00000001909df004 00EA1426-38F7-3FD2-BE01-04EBD44ECA35 + 11669508
25 UIKitCore 0x00000001909e45d8 UIApplicationMain + 164
26 APPNAME 0x0000000100423468 main + 88
27 libdyld.dylib 0x000000018ddf8598 77E57314-8A58-3064-90C0-8AF9A4745430 + 5528
)
App doesn't crash but after this error, if I use Xcode's debugger to print the current keyWindow, it's set to UITextEffectsWindow
(as the error warns about).
(lldb) po UIApplication.shared.keyWindow
▿ Optional<UIWindow>
- some : <UITextEffectsWindow: 0x135ede920; frame = (0 0; 375 667); opaque = NO; autoresize = W+H; layer = <UIWindowLayer: 0x2815009e0>>
This causes any further view controller presentations using UIApplication.shared.keyWindow?.rootViewController
and self.present
to fail as the keyWindow is UITextEffectsWindow
and not my AppDelegate's window.
I am really not sure why this is happening. I am not messing around with keywindow anywhere in my app.
A workaround solution to fix this is that I can set the keywindow back to my AppDelegate's window by using:
(UIApplication.shared.delegate as? AppDelegate)?.window?.makeKeyAndVisible()
And things start working fine. However I would prefer to have a proper solution instead of this workaround. I think the UITextEffectsWindow
is something which was introduced in iOS 13 to handle the gestures for handling Undo & Redo Typing etc but I could be wrong:
https://ios.gadgethacks.com/how-to/undo-redo-typing-with-ios-13s-new-gestures-0201481/
Is there a way to prevent this?
If not, is there a way to disable the undo/redo gestures?
Note that this app was developed during iOS 11 I think and it doesn't have the SceneDelegate stuff (unless Xcode somehow added it when the project was upgraded).
EDIT: I found the following way to disable the iOS 13 gestures:
extension UITextField {
@available(iOS 13.0, *)
open override var editingInteractionConfiguration: UIEditingInteractionConfiguration {
print("editingInteractionConfiguration!!!!!!!!!!!")
return .none
}
}
This does print my breakpoint but the UITextEffectsWindow should not become key.
warning still gets logged in console. So maybe the issue is with something else.
Upvotes: 6
Views: 1882