Search code examples
iosobjective-ciphonexcodeuiactivityviewcontroller

UIActivityViewController issue with the Edit Actions title - SHARE_SHEET_EDIT_ACTIONS_BUTTON_TITLE


I'm facing an issue related to the UIActivityViewController with Edit Actions title.

It shows SHARE_SHEET_EDIT_ACTIONS_BUTTON_TITLE instead of Edit Actions..

Findings:

  1. Working fine in the other apps such as WhatsApp and Instagram.
  2. The same code is working fine in the newly created iOS apps.
  3. Tested in iOS 15.0 and iOS 14.0+ using Xcode Version 13.1.
  4. Tested on both Device and Simulators.

Notes:

The project is in ObjectiveC and created before 3 years.

Code:

NSString* shareText = @"Sharing an eddress with you";
NSURL *website = [NSURL URLWithString:@"http://eddress.co/EDDRSS"];
NSArray *shareArray = @[shareText, website];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:shareArray applicationActivities:nil];
[activityVC setValue:@"Someone shared an eddress with you" forKey:@"subject"];
NSArray *excludeActivities = @[UIActivityTypeAirDrop,
                                   UIActivityTypePrint,
                                   UIActivityTypeAssignToContact,
                                   UIActivityTypeSaveToCameraRoll,
                                   UIActivityTypeAddToReadingList,
                                   UIActivityTypePostToFlickr,
                                   UIActivityTypePostToVimeo];
activityVC.excludedActivityTypes = excludeActivities;
[self presentViewController:activityVC animated:YES completion:nil];

Screenshots:

enter image description here

enter image description here

Any help on this is highly appreciated.


Solution

  • Finally I found the root cause and solution for this. All was happened due to the Localization

    Below code is the real culprit

    #pragma mark - Method Swizzling
    - (NSString *)customLocaLizedStringForKey:(NSString *)key value:(NSString *)value table:(NSString *)tableName {
        NSBundle*bundle = [BundleLocalization sharedInstance].localizationBundle;
        return [bundle customLocaLizedStringForKey:key value:value table:tableName];
    }
    

    This returns SHARE_SHEET_EDIT_ACTIONS_BUTTON_TITLE instead of Edit Actions..

    See the below Log

    key:SHARE_SHEET_EDIT_ACTIONS_BUTTON_TITLE value: tableName:Localizable
    return: SHARE_SHEET_EDIT_ACTIONS_BUTTON_TITLE
    key:SHARE_SHEET_EDIT_SECTION_TITLE_FAVORITES value: tableName:Localizable
    return: SHARE_SHEET_EDIT_SECTION_TITLE_FAVORITES
    key:SHARE_SHEET_EDIT_ACTIONS_BUTTON_TITLE value: tableName:Localizable
    return: SHARE_SHEET_EDIT_ACTIONS_BUTTON_TITLE
    key:Copy[Activity] value:Copy tableName:Localizable
    return: Copy
    key:SHARE_SHEET_EDIT_ACTIONS_BUTTON_TITLE value: tableName:Localizable
    return: SHARE_SHEET_EDIT_ACTIONS_BUTTON_TITLE
    key:SHARE_SHEET_DEFAULTS_REMOVE_BUTTON_TITLE value: tableName:Localizable
    return: SHARE_SHEET_DEFAULTS_REMOVE_BUTTON_TITLE
    key:Copy[Activity] value:Copy tableName:Localizable
    return: Copy
    key:SHARE_SHEET_EDIT_SECTION_TITLE_OTHER value: tableName:Localizable
    return: SHARE_SHEET_EDIT_SECTION_TITLE_OTHER
    key:SHARE_SHEET_EDIT_ACTIONS_BUTTON_TITLE value: tableName:Localizable
    return: SHARE_SHEET_EDIT_ACTIONS_BUTTON_TITLE
    

    Temporary Solution:

    #pragma mark - Method Swizzling
    
    - (NSString *)customLocaLizedStringForKey:(NSString *)key value:(NSString *)value table:(NSString *)tableName {
        if ([key isEqualToString:@"SHARE_SHEET_EDIT_ACTIONS_BUTTON_TITLE"]) {
            return @"Edit Actions...";
        }
        else if ([key isEqualToString:@"SHARE_SHEET_EDIT_SECTION_TITLE_FAVORITES"]) {
            return @"Favorites";
        }
        else if ([key isEqualToString:@"SHARE_SHEET_EDIT_SECTION_TITLE_OTHER"]) {
            return @"Other Actions";
        }
        else if ([key isEqualToString:@"SHARE_SHEET_EDIT_SECTION_TITLE_SUGGESTIONS"]) {
            return @"Suggestions";
        }
        else if ([key isEqualToString:@"SHARE_SHEET_DEFAULTS_REMOVE_BUTTON_TITLE"]) {
            return @"Remove";
        }
        else {
            NSBundle *bundle = [BundleLocalization sharedInstance].localizationBundle;
            return [bundle customLocaLizedStringForKey:key value:value table:tableName];
        }
    }