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:
- Working fine in the other apps such as WhatsApp and Instagram.
- The same code is working fine in the newly created iOS apps.
- Tested in iOS 15.0 and iOS 14.0+ using Xcode Version 13.1.
- Tested on both Device and Simulators.
Notes:
-
App is using Localization (Bahasa Langauge)
-
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];
Any help on this is highly appreciated.
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];
}
}