1

我已经为 irate 添加了 .h .m 和 .bundle 文件。我将预览模式设置为“是”,因此当我的应用在手机上启动时会立即弹出警报视图(我正在测试)。如果我不将预览模式设置为“是”,它根本不会显示警报视图。所以现在它会弹出评级警报视图。在 .m 文件中,我尝试编辑字符串中的标题、消息和按钮文本,它仍然显示原始标题、消息和按钮文本,即使它在 .m 中不存在,因为我已经完全改变了它。有谁知道如何编辑此文本,以便编辑出现在警报视图上的文本。代码如下,因为它来自我下载的 irate。如果我更改字符串中的文本,它在我测试时不会改变,它仍然会显示现在的内容。在这里转圈,我猜我

- (NSString *)messageTitle
{
    return [_messageTitle ?: [self localizedStringForKey:iRateMessageTitleKey  withDefault:@"Rate %@"] stringByReplacingOccurrencesOfString:@"%@" withString:self.applicationName];
}

- (NSString *)message
{
NSString *message = _message;
if (!message)
{
    message = (self.appStoreGenreID == iRateAppStoreGameGenreID)? [self localizedStringForKey:iRateGameMessageKey withDefault:@"If you enjoy playing %@, would you mind taking a moment to rate it? It won’t take more than a minute. Thanks for your support!"]: [self localizedStringForKey:iRateAppMessageKey withDefault:@"If you enjoy using %@, would you mind taking a moment to rate it? It won’t take more than a minute. Thanks for your support!"];
}
return [message stringByReplacingOccurrencesOfString:@"%@" withString:self.applicationName];
}

- (NSString *)cancelButtonLabel
{
return _cancelButtonLabel ?: [self localizedStringForKey:iRateCancelButtonKey withDefault:@"No, Thanks"];
}

- (NSString *)rateButtonLabel
{
return _rateButtonLabel ?: [self localizedStringForKey:iRateRateButtonKey withDefault:@"Rate It Now"];
}

- (NSString *)remindButtonLabel
{
return _remindButtonLabel ?: [self localizedStringForKey:iRateRemindButtonKey withDefault:@"Remind Me Later"];
}
4

1 回答 1

1

正如GitHub 上的 iRate 文档中所建议的,有两种方法可以覆盖这些字符串:

1)您可以在您的应用委托初始化类方法中覆盖默认字符串:

+ (void)initialize
{
    //overriding the default iRate strings
    [iRate sharedInstance].messageTitle = NSLocalizedString(@"Rate MyApp", @"iRate message title");
    [iRate sharedInstance].message = NSLocalizedString(@"If you like MyApp, please take the time, etc", @"iRate message");
    [iRate sharedInstance].cancelButtonLabel = NSLocalizedString(@"No, Thanks", @"iRate decline button");
    [iRate sharedInstance].remindButtonLabel = NSLocalizedString(@"Remind Me Later", @"iRate remind button");
    [iRate sharedInstance].rateButtonLabel = NSLocalizedString(@"Rate It Now", @"iRate accept button");
}

2) 推荐的方法是您也可以创建自己的 Localizable.strings 文件并添加在 iRate.h 中找到的那些字符串:

//localisation string keys
static NSString *const iRateMessageTitleKey = @"iRateMessageTitle";
static NSString *const iRateAppMessageKey = @"iRateAppMessage";
static NSString *const iRateGameMessageKey = @"iRateGameMessage";
static NSString *const iRateCancelButtonKey = @"iRateCancelButton";
static NSString *const iRateRemindButtonKey = @"iRateRemindButton";
static NSString *const iRateRateButtonKey = @"iRateRateButton";

例如,在 Localizable.strings 文件中:

"iRateMessageTitle" = "My own rating title";
"iRateAppMessage" = "My own rating message";
于 2013-07-03T00:55:46.630 回答