Reputation: 333
I am working on a iOS keyboard extension. It works fine, but the run-time memory used by it gets almost double if I minimize any current app and open the keyboard in another app.
To explain it better, let me give you an example.
Suppose I opened the keyboard in the "Notes" app, it takes around 15 MB(first launch). Now if I minimize "Notes" and open the keyboard in "Safari", the memory goes to 21 MB.
So, my question is that is there any way to dismiss the keyboard if the app running it is minimised?
Any help is appreciated. Thanks
Upvotes: 1
Views: 396
Reputation: 4805
You could sign up for the NSExtensionHostWillEnterBackground
/ NSExtensionHostWillResignActive
notifications, and compare the extension context object to your UIInputViewController
's extension context object to see that the host app of any individual input view controller is disappearing.
With that said, it sounds like you're leaking your UIInputViewController
subclass, or at least some of its contents.
You should profile your keyboard extension for leaks/heap growth and ensure that any resources that are only needed by one instance of the keyboard are deallocated by the time its input view has been hidden.
Upvotes: 1
Reputation: 141
In your AppDelegate.m :
- (void)applicationDidEnterBackground:(UIApplication *)application{
[self.window endEditing:YES];
}
Upvotes: 0