首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在irate for ios中编辑标题和消息?

如何在irate for ios中编辑标题和消息?
EN

Stack Overflow用户
提问于 2013-07-03 08:23:09
回答 1查看 419关注 0票数 1

我已经为irate添加了.h .m和.bundle文件。我将预览模式设置为YES,这样当我的应用程序在我的手机上启动时(我正在测试),Alert View就会弹出。如果我没有将预览模式设置为YES,它根本不会显示Alert View。因此,现在它会弹出评级警报视图。在.m文件中,我尝试编辑字符串中的标题、消息和按钮文本,它仍然显示原始的标题、消息和按钮文本,即使它在.m中不存在,因为我已经完全更改了它。是否有人知道如何编辑此文本,以便它可以编辑出现在Alert View上的文本。代码如下,因为它来自我下载的irate。如果我改变字符串中的文本,当我测试时它不会改变,它仍然显示当前的内容。在这里转来转去,我猜我错过了一些简单的东西,任何帮助都会很棒!

代码语言:javascript
复制
- (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"];
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-07-03 08:55:47

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

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

代码语言:javascript
复制
+ (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中找到的字符串:

代码语言:javascript
复制
//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文件中:

代码语言:javascript
复制
"iRateMessageTitle" = "My own rating title";
"iRateAppMessage" = "My own rating message";
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17437851

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档