mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-21 00:52:43 +02:00
App extension - Improvement: Reduce memory consumption.
Force the ShareExtensionManager to release the primary view controller when the action is completed. We observed that `dealloc` is called for this view controller when the request is cancelled with error (`cancelRequestWithError`), but it is not called when the request is completed (`completeRequestReturningItems`).
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
|
||||
@interface SharePresentingViewController ()
|
||||
|
||||
@property (nonatomic) ShareViewController *shareViewController;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SharePresentingViewController
|
||||
@@ -28,21 +30,33 @@
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[ShareExtensionManager sharedManager].shareExtensionContext = self.extensionContext;
|
||||
ShareExtensionManager *sharedManager = [ShareExtensionManager sharedManager];
|
||||
|
||||
sharedManager.primaryViewController = self;
|
||||
sharedManager.shareExtensionContext = self.extensionContext;
|
||||
|
||||
[self presentShareViewController];
|
||||
}
|
||||
|
||||
- (void)destroy
|
||||
{
|
||||
if (self.shareViewController)
|
||||
{
|
||||
[self.shareViewController destroy];
|
||||
self.shareViewController = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)presentShareViewController
|
||||
{
|
||||
ShareViewController *shareViewController = [[ShareViewController alloc] init];
|
||||
self.shareViewController = [[ShareViewController alloc] init];
|
||||
|
||||
shareViewController.providesPresentationContextTransitionStyle = YES;
|
||||
shareViewController.definesPresentationContext = YES;
|
||||
shareViewController.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
||||
shareViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
|
||||
self.shareViewController.providesPresentationContextTransitionStyle = YES;
|
||||
self.shareViewController.definesPresentationContext = YES;
|
||||
self.shareViewController.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
||||
self.shareViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
|
||||
|
||||
[self presentViewController:shareViewController animated:YES completion:nil];
|
||||
[self presentViewController:self.shareViewController animated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
|
||||
Reference in New Issue
Block a user