Skip to content

Commit

Permalink
Fix image viewer not always showing share sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
NSExceptional committed Sep 14, 2019
1 parent 07f0b07 commit d537d3c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
8 changes: 8 additions & 0 deletions Classes/Core/FLEXTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ - (void)viewDidAppear:(BOOL)animated {
}
}

- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];

if (self.searchController.active) {
self.searchController.active = NO;
}
}

#pragma mark - Private

- (void)debounce:(void(^)())block {
Expand Down
23 changes: 15 additions & 8 deletions Classes/ViewHierarchy/FLEXImagePreviewViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,29 +81,36 @@ - (void)centerContentInScrollViewIfNeeded

- (void)actionButtonPressed:(id)sender
{
static BOOL CanSaveToCameraRoll = NO;
static BOOL canSaveToCameraRoll = NO, didShowWarning = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if ([UIDevice currentDevice].systemVersion.floatValue < 10) {
CanSaveToCameraRoll = YES;
canSaveToCameraRoll = YES;
return;
}

NSBundle *mainBundle = [NSBundle mainBundle];
if ([mainBundle.infoDictionary.allKeys containsObject:@"NSPhotoLibraryUsageDescription"]) {
CanSaveToCameraRoll = YES;
} else {
NSLog(@"Add NSPhotoLibraryUsageDescription in app's Info.plist for saving captured image into camera roll.");
canSaveToCameraRoll = YES;
}
});

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[self.image] applicationActivities:@[]];

if (!CanSaveToCameraRoll) {
if (!canSaveToCameraRoll && !didShowWarning) {
activityVC.excludedActivityTypes = @[UIActivityTypeSaveToCameraRoll];

didShowWarning = YES;
NSString *msg = @"Add 'NSPhotoLibraryUsageDescription' to this app's Info.plist to save images.";
[FLEXAlert makeAlert:^(FLEXAlert *make) {
make.title(@"Reminder").message(msg);
make.button(@"OK").handler(^(NSArray<NSString *> *strings) {
[self presentViewController:activityVC animated:YES completion:nil];
});
} showFrom:self];
} else {
[self presentViewController:activityVC animated:YES completion:nil];
}

[self presentViewController:activityVC animated:YES completion:nil];
}

@end

0 comments on commit d537d3c

Please sign in to comment.